繁体   English   中英

select 记录与模式匹配

[英]select records with pattern matching

我的表在 searchtxt 字段“约翰·史密斯先生”中有文本,即使用户输入任何类似的输入,我也想搜索此文本:-“mrjohan”或“史密斯先生”或“约翰先生”或“MR.johan” "Nomatch word johan" 等。但查询结果应选择johan smith 先生的记录。 我如何搜索该记录以匹配上述模式。

到目前为止,我已经尝试过这个查询: -

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

但是不能成功,有什么想法用 REGEXP 来做吗?

非常感谢... :)

我建议使用像Sphinx这样的全文搜索引擎。

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

另一种解决方案是在使用LIKE之前对输入进行预处理

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM