I am working on a search query. I have a string "thomas alva edison" in my table. I want to display this string if the user searches for,
thomas alva edison,thomas,alva,edison,thomas alva,thomas edison,etc
but not for
tho,son,alv,etc
what I did is
select name from tbl_names where name like "."'%".$key."%'
How can I modify this query to get the correct results.
I recommended to use REGEXP for word search in query,
A query should be like:
SELECT name FROM `tbl_names` WHERE `name` REGEXP '[[:<:]]thomas[[:>:]]'
Hope this will be useful to you. For more details please check this Check this answer.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句