Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1069641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:26:50+00:00 2026-05-16T20:26:50+00:00

I am using a MySQL Database to search through a list of categories. My

  • 0

I am using a MySQL Database to search through a list of categories. My query is:

select * from cat where name REGEXP(‘(region_Long Island)+(.)*(sport_Outdoor Track)’);

where the values “region_Long Island” and “sport_Outdoor Track” are passed in. I need to be able to match these categories, regardless of the order they are in. In the table, it is possible to have various combinations of these two categories. I need to match any records that have both of these categories, regardless of what order they are listed in.

I am not able to change the query itself, only modify what is passed into th REGEXP function.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:26:50+00:00Added an answer on May 16, 2026 at 8:26 pm

    If you can use only a single regexp and you can’t change the SQL query, then to match both A and B in any order, you need a regexp that matches AB or BA:

    'region_Long Island.*sport_Outdoor Track|sport_Outdoor Track.*region_Long Island'
    

    Re your comment:

    What about cases where there are more than two, in any particular order?

    If you had patterns A, B, and C any you needed to find all three in any order, you’d need a regexp that matches ABC, ACB, CAB, CBA, BAC, or BCA. This quickly starts to look like you need n! permutations if you have n patterns.

    That’s why a single regular expression is not a good solution for these cases. You’re going to have to use another approach.

    I am not able to change the query itself, only modify what is passed into the REGEXP function.

    Sorry, that’s not going to work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to search through a MySQL table using values from
Is it possible to search through a MySQL database using blob data to find
I'm using a MySQL database. I have a products database where users can search
I'm using a MySQL database and accessing it through Java. PreparedStatement prep1 = this.connection.prepareStatement(
I'm searching a fairly large article database using full text search in mysql and
I am using mysql database ... I have a table with col name food_type
I am using MySQL fulltext and PHP (codeigniter) to search a database containing RSS
I'm attempting to construct a search query in MySQL using multiple arguments, and I
I'm using Mysqli OO to search the database for 2 specific values using the
I'm using Mysql database and neatbeans IDE conncting by mysql-connector-java-5.1.21 jdbc , and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.