Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 选择模式匹配的记录_Php_Mysql_Regex_Select Query - Fatal编程技术网

Php 选择模式匹配的记录

Php 选择模式匹配的记录,php,mysql,regex,select-query,Php,Mysql,Regex,Select Query,我的表格在searchtxt字段“Mr.johan smith”中有文本,我希望搜索此文本,即使用户输入的输入像任何一个一样:-“mrjohan”或“Mr.smith”或“Mr.johan”或“Mr.johan”,“Nomatch word johan”等。但应根据查询结果选择Mr.johan smith的记录。如何搜索该记录以匹配上述模式 到目前为止,我尝试了以下问题:- select t.* from temp_textsearch t where t.searchtxt like '%U

我的表格在searchtxt字段“Mr.johan smith”中有文本,我希望搜索此文本,即使用户输入的输入像任何一个一样:-“mrjohan”或“Mr.smith”或“Mr.johan”或“Mr.johan”,“Nomatch word johan”等。但应根据查询结果选择Mr.johan smith的记录。如何搜索该记录以匹配上述模式

到目前为止,我尝试了以下问题:-

select t.* from temp_textsearch t
where t.searchtxt  like '%UserInput%'
但是如果不能成功,有没有办法用REGEXP来实现呢


非常感谢……:)

我建议使用全文搜索引擎,如。

可能SQL函数全文可用:


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

您是否同意匹配“smith先生”或“johan先生”或“johan先生”,但不匹配您建议的其他人?我认为分隔关键字的空间很重要。对于任何记录,单词可能是任意的。