我想转换一下:
SELECT id,songTitle,artistName, trackId
FROM songs
WHERE (songTitle, artistName) IN (('come together', 'the beatles'),('all the small things', 'blink-182'))
对于这样的事情,但我不知道正确的语法:
SELECT id,songTitle,artistName, trackId
FROM songs
WHERE (songTitle, artistName) IN LIKE (('%come together%', '%the beatles%'),('%all the small things%', '%blink-182%'))
除了我一次搜索100多首歌曲。我们也可以使用REGEXP,我只是不知道其中任何一个的正确语法。
答案 0 :(得分:1)
WHERE (a,b) IN ((1,2), ...)
的优化效果非常差。LIKE
中的主要外卡阻止使用索引。因此,除了性能之外,我们来看看如何执行任务:
WHERE ( songTitle LIKE '%come together%' AND artistName LIKE '%the beatles%')
OR ( .... )
OR ...
对不起,没有捷径。
在这种情况下,REGEXP无法帮助 。
FULLTEXT
索引是需要考虑的事情,但我不认为它会对此示例有所帮助。