【发布时间】:2018-05-24 10:16:57
【问题描述】:
我有一个问题,
例如
名称列有“Rodrigue Dattatray Desilva”。
我想以这样的方式编写查询,
如果我搜索“gtl”并匹配字符串中的任何位置,它应该会显示结果。
我知道在 PHP 中我可以应用 '%g%t%l%' 之类的补丁。
但是我想了解MySql的方式。
注意:我可以搜索任何东西,我只是举个例子。
编辑:
create table Test(id integer, title varchar(100));
insert into Test(id, title) values(1, "Rodrigue Dattatray Desilva");
select * from Test where title like '%g%t%l%';
考虑上述情况。其中“gtl”是我试图在标题中搜索的字符串,但搜索字符串可以是任何内容。
gtl 是字符串,它存在于当前标题中但不按顺序存在。
【问题讨论】:
-
我认为 'STRCMP()' 是你想要的。见here