Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/83.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
Mysql 选择SQL中与输入部分匹配的行_Mysql_Sql - Fatal编程技术网

Mysql 选择SQL中与输入部分匹配的行

Mysql 选择SQL中与输入部分匹配的行,mysql,sql,Mysql,Sql,我想在我的表中选择包含在字符串中的内容的行(我正在使用GoogleSheet) 例如,名为Jobportal,列Test的表中包含的行: How to find work Work permit Jobs Temporary jobs 我想选择包含我输入的任何单词的所有行,因此如果我写“我正在找工作”,我需要选择行Jobs和临时Jobs。如果我写“我的工作在哪里?”,我需要选择如何找到工作和工作许可证 我尝试了此查询,但它返回了错误/意外的结果 select * from Jobportal

我想在我的表中选择包含在字符串中的内容的行(我正在使用GoogleSheet)

例如,名为
Jobportal
,列
Test
的表中包含的行:

How to find work
Work permit
Jobs
Temporary jobs
我想选择包含我输入的任何单词的所有行,因此如果我写“我正在找工作”,我需要选择行
Jobs
临时Jobs
。如果我写“我的工作在哪里?”,我需要选择
如何找到工作
工作许可证

我尝试了此查询,但它返回了错误/意外的结果

 select * from Jobportal where 'im looking for a job' LIKE CONCAT('%',Test,'%');

您可以使用正则表达式。假设用户类型没有特殊字符:

where test regexp replace('im looking for a job', ' ', '|')

这样说,对于性能,您可能需要考虑使用性能。

您可能希望使用FultLeXT索引。因为否则,您需要将搜索短语拆分为单词,然后使用每个单词进行
搜索。如果考虑“是”、“和”、“到”这样的词,这个解决方案就不是最优的。借助全文索引执行的搜索可能有助于解决此类问题。对于mysql,您可能会在此处找到一些内容:。