Results 1 to 2 of 2
Thread: MySQL Search Query
Feb 9, 2010, 01:46 #1
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?
Feb 9, 2010, 02:06 #2
- Join Date
- Mar 2002
- Bristol, UK
- 0 Post(s)
- 0 Thread(s)
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 searchSam Hastings