我想运行这样的东西:
select * from table where field in ("%apple%", "%orange%")
有办法吗?或者至少有比为每个关键字动态构建查询更好的方法:
select * from table where field like "%apple%" or field like "%orange%"
谢谢。
最佳答案
我不确定它是否比您想出的更好,但您可以使用 MySQL's regex capabilities :
select * from my_table where field rlike 'apple|orange';
另外,正如其他人所提到的,您可以使用 MySQL's full text search功能(但前提是您使用的是 MyISAM 引擎)。
关于sql - 我可以在 "IN"MySQL 语句中使用通配符吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1652318/