MySQL Search Query
You might have seen on websites that they allow you to search by:
So for the first one i.e exact word, we use the SQL clause WHERE TITLE = 'xyz'
For the "all words" search we use the SQL clause WHERE TITLE LIKE '%xyz%'
(Pls correct me if I am wrong with the above)
I was wondering how do we make an mysql search for search strings like "hello world", such that if either the word "hello" is found anywhere in the TITLE column or the word "world" is found in the TITLE column, it should display the matching results.
Pls can anyone help me out?
WHERE title LIKE '%hello world%'
WHERE title LIKE '%hello%' OR title LIKE '%world%'
WHERE title LIKE '%hello%' AND title LIKE '%world%'
Note there will be some work your application logic will have to carry out in order to split a search term up into multiple words, if necessary for the search :)