开发者

select records with pattern matching

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜