[英]How to convert WHERE IN clause with multiple values to RegExp or Like
I want to convert this: 我想将其转换为:
SELECT id,songTitle,artistName, trackId
FROM songs
WHERE (songTitle, artistName) IN (('come together', 'the beatles'),('all the small things', 'blink-182'))
To something like this but I don't know the right syntax: 对于这样的事情,但我不知道正确的语法:
SELECT id,songTitle,artistName, trackId
FROM songs
WHERE (songTitle, artistName) IN LIKE (('%come together%', '%the beatles%'),('%all the small things%', '%blink-182%'))
Except I'm searching 100s of more songs at once. 除了我要一次搜索数百首歌曲。 We could use REGEXP too I just don't know the right syntax for either of those. 我们也可以使用REGEXP,我只是不知道哪种语法正确。
WHERE (a,b) IN ((1,2), ...)
is very poorly optimized. WHERE (a,b) IN ((1,2), ...)
优化非常差。 LIKE
prevents use of an index. LIKE
前导通配符阻止使用索引。 So, performance aside, let's look at how to perform the task: 因此,除了性能之外,让我们看一下如何执行任务:
WHERE ( songTitle LIKE '%come together%' AND artistName LIKE '%the beatles%')
OR ( .... )
OR ...
Sorry, there is no short cut. 抱歉,没有捷径。
REGEXP can't help in this case . REGEXP 在这种情况下无济于事。
FULLTEXT
indexing is something to consider, but I don't see that it would help in this example. FULLTEXT
索引是要考虑的事情,但是在此示例中,我认为它没有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.