Hi
I have a column named
Tags of varchar type which hold tags separated by commas.
Example of a possible field value for
Tags:
bikes, road trip, summer
Code:
SELECT * FROM `tablename` WHERE `Tags` LIKE '%road%'
will obviously select the example row but it shouldn't since it doesn't come under
road but under
road trip.
Using PHP's preg_match is easy but in this case I need a SQL solution.
How do I go abt making the condition for the query using the Regexp
(^|,\s*)road(\s*,|$) ?
Now I got this to work and it doesnt select the
road trip row for
road, but neither does it get selected for
road trip
Code:
(^|,\s*)road trip(\s*,|$)
Any idea what I might be dong wrong here ?
Thanx