gpt4 book ai didi

sql - 我可以在 "IN"MySQL 语句中使用通配符吗?

转载 作者:IT老高 更新时间:2023-10-29 00:11:57 25 4
gpt4 key购买 nike

我想运行这样的东西:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com