假设:
短语1:我是蜘蛛侠,我有一个土豆
短语2:我是一只蜘蛛,我喜欢土豆
表格:
column_id | column_str
1 | spiderman
2 | potatoes
我想执行一个sql查询,其中输入是短语,结果应该是:
对于第1阶段:
column_id | column_str
1 | spiderman
对于第2阶段:
column_id | column_str
2 | potatoes
因此,它应该在表列\u str列的输入中找到匹配的子字符串,并返回其关联的id。
我还没有错误或尝试的例子,因为我不知道从哪里开始。
我只知道 %LIKE%
匹配器。但这恰恰相反,就像 %IN_LIKE%
.
2条答案
按热度按时间nhaq1z211#
您应该考虑一些棘手的sql,如下所示:
例子:
rqdpfwrv2#
你只需要
INSTR
功能:见mysql
INSTR()
函数以供参考。