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 8928147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:22:15+00:00 2026-06-15T08:22:15+00:00

I am trying to condense the below query which could have unlimited options based

  • 0

I am trying to condense the below query which could have unlimited options based on a web form field. Users can input as many title keywords separated by commas. So my query would be constructed like the below with unlimited arguments:

"SELECT title FROM titles WHERE 
 title LIKE '%blue%' 
 AND
 title like '%red%'
 AND
 title like '%green%'
 AND
 title like '%yellow%'
 ...";

Looking at this link, MySQL LIKE IN()?, it shows a good example of using regular expression, but it is using “OR”.

SELECT * from fiberbox where field REGEXP '1740|1938|1940';

What is the equivalent of using “AND”? For example, in quasi-SQL:

SELECT * from titles WHERE title REGEXP 'blue && red && green && yellow';
  • 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-06-15T08:22:16+00:00Added an answer on June 15, 2026 at 8:22 am

    AND is a bit more difficult to do with regexes, and it doesn’t seem to be possible with MySQL’s limited regular expression syntax. If you are using the myISAM engine or MySQL 5.6, you can use the MATCH() function to get most of what you want:

    SELECT title FROM titles WHERE MATCH (title)
    AGAINST ('+red* +green* +yellow*' IN BOOLEAN MODE);
    

    However, I would recommend sticking to your simple chaining of ANDs. It’s less fragile, more powerful, and easier to code.

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

Sidebar

Related Questions

I'm trying to work out if I can condense a number of regex's into
In order to condense my code I am trying to make one of my
Trying to figure out how I can do this properly. The print_r looks like
trying to figure out why this is happening - I have an input text
I'm trying to identify and condense single (uppercase) characters in a string. For example:
I am trying to start learning OO JS and have one quick question (i
I am trying to embed different typefaces of a font and have a .otf
I'm trying to append a form to a div tag $('#courses_ajax').html('<h1>Materie: <%= @course.name %></h1>');
I am trying to condense my CSS a bit but I've hit a snag
I am trying to write a loop that will cycle through colors and condense

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.