Can’t seem to find documentation on a particular formation of SQL using the LIKE operator. Using MySQL, a typical query for multiple words using the LIKE operator may look like this:
SELECT * from table AS t WHERE t.col LIKE '%word1%' AND t.col LIKE '%word2%'
Although the following statement also works, the rows returned will vary depending on the order of the words in the query. For example:
SELECT * from table WHERE col LIKE '%word1%' '%word2%'
executes without the AND boolean, but with different results from:
SELECT * from table WHERE col LIKE '%word2%' '%word1%'
My question is, what is actually happening when using this formation of the query instead of using boolean?
From the manual:
So, what’s happening is that
'%word1%' '%word2%'is being interpreted as ‘%word1%%word2%’