php, mysql single query for multipe columns distinct values
75
Is it possible to retrieve records using single query in case like:
id title tags
1 First yellow,blue
2 Second green, yellow,red,
3 Third black,purple
What I would like to do is select all records where keyword yellow appears. The result should return two records "First and Second"
Answer
Solution:
Better to use
REGEX
to get exact searchOr you can also use
FIND_IN_SET()
functionNOTE:
FIND_IN_SET()
function won't work correctly if tags not symmetric comma separated, iftags
have white space between,
then it would create problem