我可以在"IN"中使用通配符吗? MySQL语句? [英] Can I use wildcards in "IN" MySQL statement?
本文介绍了我可以在"IN"中使用通配符吗? MySQL语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想运行以下内容:
select * from table where field in ("%apple%", "%orange%")
有办法吗?或者至少有比动态构建每个关键字查询更好的方法:
Is there a way? Or at least is there a better way than dynamically building query for every keyword:
select * from table where field like "%apple%" or field like "%orange%"
谢谢.
推荐答案
I'm not sure it's any better than what you came up with but you could use MySQL's regex capabilities:
select * from my_table where field rlike 'apple|orange';
此外,正如其他人提到的那样,您可以使用 MySQL的完整版本文本搜索功能(但仅在使用MyISAM引擎的情况下).
Also, as others have mentioned, you could use MySQL's full text search capabilities (but only if you're using the MyISAM engine).
这篇关于我可以在"IN"中使用通配符吗? MySQL语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文