Jump to content

regular expression in a query?


jeff5656

Recommended Posts

Could someone please help me with the code that will select records only if there are certain keywords in two of the fields?

 

for instance:

$query = "select * from table_a where (column_a REGEXP 'apple' OR 'kiwi') 
OR (column_b REGEXP 'apple' OR 'kiwi) WHERE status = 'active' ";

So if the record contains apple or kiwi anywhere in column_a OR column_b, then select that record.

I know you have to use regexp because the contents of column_a is a big text with a few sentences or paragraphs of text, and I only want to select the record if it contains those two words (and same for column_b).

 

 

Link to comment
https://forums.phpfreaks.com/topic/221769-regular-expression-in-a-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.