开发者

select records with pattern matching

开发者 https://www.devze.com 2023-03-16 05:51 出处:网络
My table has text in searchtxt field \"Mr. johan smith\" and i want to search this text even if the user enters inputs like any one :-\"mrjohan\" or \"mr smith\" or \"mr johan\" or \"MR.johan\",\"Noma

My table has text in searchtxt field "Mr. johan smith" and i want to search this text even if the user enters inputs like any one :- "mrjohan" or "mr smith" or "mr johan" or "MR.johan","Nomatch word johan" etc. But the Mr. johan smith's record should be selected as a result from query. How can i search that record to matching above pattern.

So far i have tried with this query:-

select t.* from temp_textsearch t
where t.searchtxt  like '%UserInput%'

But can't success, any idea with REGEXP to do it ?

Thanks a开发者_运维问答 lot ... :)


I'd recommend to use a fulltext search engine like Sphinx.


Maybe the SQL function FULLTEXT can be usefull : http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

An other solution is to pre-process the input before using LIKE

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号