keyword = house
SELECT * FROM products WHERE description LIKE '%house%'
This query also returns records having keyword, for example, courthouse, but I want to look for house only. How do I search anywhere in the description for “house” only?
Thanks.
UPDATE
just for more clarification ..
actually house, can be at
- the start of the description .. "House for sale..",
- can be quoted -- "house", 'house'
- can have exclamation .. house!!!, house!
- others - house? etc ..
this is why I used %house%
SELECT * FROM products WHERE description rlike ‘[[:<:]]house[[:>:]]’
rlike is synonim for REGEXP.
[[:<:]] denotes the start of the word and the
[[:>:]] end of the word.
It works for all your requirements (case insensitive, with quoted words or words ending, or begging, with exclamation points and other non-letter characters)