MySQL Forums
Forum List  »  Newbie

multiple condition SELECT statement and regex
Posted by: Prince oDD
Date: February 12, 2009 02:08PM

I am trying to find the correct syntax for using multiple OR and AND statments along with REGEX. This is what I am using, but it does not work. Could someone help me find what is incorrect?

FROM figure_list
WHERE number > 0
AND (keywords REGEXP '^soldier,'
OR keywords REGEXP '$,soldier'
OR keywords LIKE ',soldier,'
OR keywords = 'soldier')
ORDER BY set_name, col_num
LIMIT 0 , 400;

I am trying to run query to match the following in a column called 'keywords'. Each word in the 'keywords' column has one or more strings seperated by commas.
Poop,Soldier,Celery,Access to the Sacred Heart
Soldier,Hangman,Hearts,Mangos,Expect Warriors

by not the following
Apple,Orange,Carrot Soldiers,Poop

Thanks for the help.

Options: ReplyQuote

Written By
multiple condition SELECT statement and regex
February 12, 2009 02:08PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.