I've got a query that looks something like this:
SELECT
*
FROM table
WHERE
(col1, col2) in (
('col1_val1', 'col2_val1'),
('col1_val2', 'col2_val2'),
('col1_val3', 'col2_val3'),
)
This works in MySQL, but fails in sqlite3 with a syntax error:
Error: near ",": syntax error
How can I rewrite this query to an equivalent one that works in sqlite3?
Choose your favourite version:
http://sqlfiddle.com/#!5/6169b/9
using temporary table
data IN pairs; if pair(a,b) is not unique
data IN pairs; if pair(a,b) is unique
data NOT IN pairs; if pair(a,b) is unique
using inline table
data IN pairs; if pair(a,b) is not unique
data IN pairs; if pair(a,b) is unique
data NOT IN pairs; if pair(a,b) is unique
Here's an easy solution that works, but it might not perform well on large data sets because it can't use any of your indexes.
Try it in sqlfiddle
Enjoy!