Yes, this is how
LIKE works.
If you want to return all rows containing all of the words words "this", "is" and "red", you might code it like
It will return all fields that contain all three substrings somewhere in the field. You'd use OR instead of AND to return rows that contain at least one of the words, of course.
Another thing to try might be
- I assume you can interpret this expression yourself.
However,
LIKE is not good for identifying words, you might need to use
regular expressions.
Moreover, neither
LIKE nor regexp can utilize normal indexes. Check
MySQL full text search capabilities, otherwise your query will be a big drain on resources if the table is large or the query is run often.
(Note: the links to MySQL documentation are first hits I got from Google. They might not be entirely appropriate, I don't know MySQL and I checked them only superficially. Use them only as starting places, you should get to know these features yourself if you want to employ them.)