Reputation:
I have a table having 2000 categories.I want to search words by LIKE search. I want to get all MEN related categories
SELECT * FROM `inf_levelthree` WHERE l3_name LIKE '%men%'
It also show me wrong result like
Department Store
Women Textiles
and so on which is not related to men
What can i do so that i can get all having men only like below
Fashion - Men
Men Fashion
Mens Fashion
and so on.
Upvotes: 1
Views: 78
Reputation: 24144
Try to use REGEXP:
SELECT * FROM `inf_levelthree`
WHERE l3_name REGEXP '[[:<:]]men[[:>:]]'
or l3_name REGEXP '[[:<:]]mens[[:>:]]' ;
Upvotes: 0
Reputation: 46900
Add Spaces to your Pattern
SELECT * FROM `inf_levelthree` WHERE l3_name LIKE '% men%' OR l3_name LIKE '%men %'
This will only select those complete words which either Start with Men
or end at Men
Upvotes: 1