MySQL喜欢在()?

2022-01-30 00:00:00 sql mysql

我当前的查询如下所示:

My current query looks like this:

SELECT * FROM fiberbox f WHERE f.fiberBox LIKE '%1740 %' OR f.fiberBox LIKE '%1938 %' OR f.fiberBox LIKE '%1940 %'

我环顾四周,找不到任何类似于 LIKE IN() 的东西 - 我设想它是这样工作的:

I did some looking around and can't find anything similar to a LIKE IN() - I envision it working like this:

SELECT * FROM fiberbox f WHERE f.fiberbox LIKE IN('%140 %', '%1938 %', '%1940 %')

有什么想法吗?我是否只是以错误的方式思考问题 - 一些我从未见过的晦涩命令.

Any ideas? Am I just thinking of the problem the wrong way - some obscure command I've never seen.

MySQL 5.0.77-community-log

MySQL 5.0.77-community-log

推荐答案

A REGEXP 可能效率更高,但您必须对其进行基准测试才能确定,例如

A REGEXP might be more efficient, but you'd have to benchmark it to be sure, e.g.

SELECT * from fiberbox where field REGEXP '1740|1938|1940'; 

相关文章