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?
SELECT *
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.
Soldier
Apple,Orange,Soldier
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.