Possible Duplicate:
MySQL – How to search for exact word match using LIKE?
For example, if Im trying to get rows with the word “ever”, I could do this…
SELECT * FROM 'table' WHERE `title` LIKE %ever%
But that would also give me results for titles with the words “forever, however, never”.
How can I find only the titles which contain “ever” as its own word?
Use a
REGEXPregular expression to match using word boundaries[[:<:]]word[[:>:]]around your search term:Note that this is case-insensitive by default. For case sensitivity, you need to match it in
BINARYmode:Since it cannot make use of indexing, performance can be quite poor on large tables however.
Edit: Sorry I had PCRE boundaries in there, which MySQL doesn’t support.