Yes, this is a question that has been beaten to death, yet I believe its a tad different.
Please consider this MySQL table test
:
The desired resultset is:
In words, how can the first 3 records (id
s 1, 2, 5) be selected using exactly this string - 'Cinema, Entertainment' and in one single query? That is, how can A
be compared with the string above and have it return the record if even one 'word' matches?
Have tried the following:
SELECT * FROM test WHERE A LIKE "%Cinema, Entertainment%"
SELECT * FROM test WHERE INSTR(A, 'Cinema, Entertainment') > 0
Both return just the first record, doing an exact match.
SELECT * FROM test WHERE A LIKE '%Cinema%' OR A LIKE '%Entertainment%'
does work, but I do not want to tokenize the available string. The string could also have multiple CSV
s.
Very new to regular expressions, and cannot seem to form the right query.
Have seen these cool answers,:
...but still struggling.
Thanks in advance!