I have a table with an id and a version number (and several other fields) and I want to do a lookup for all rows that do not match the id and version I know.
I have tried something like this, but it is not quite what I wanted.
SELECT * FROM table WHERE id NOT IN (1,2,3) AND version NOT in (4,5,6);
Above query appears to work like this:
SELECT * FROM table WHERE id != 1 AND version != 4;
SELECT * FROM table WHERE id != 1 AND version != 5;
SELECT * FROM table WHERE id != 1 AND version != 6;
SELECT * FROM table WHERE id != 2 AND version != 4;
SELECT * FROM table WHERE id != 2 AND version != 5;
SELECT * FROM table WHERE id != 2 AND version != 6;
SELECT * FROM table WHERE id != 3 AND version != 4;
SELECT * FROM table WHERE id != 3 AND version != 5;
SELECT * FROM table WHERE id != 3 AND version != 6;
What I actually want, is to use the same array key for both lists, like this:
SELECT * FROM table WHERE id != 1 AND version != 4;
SELECT * FROM table WHERE id != 2 AND version != 5;
SELECT * FROM table WHERE id != 3 AND version != 6;
So this dataset returns only the second row.
id | version
------------
1 | 4
2 | 7
3 | 6
I tried to search SQL documentation for something like a for loop, but can't really find out if it exists and how it is supposed to work.