Query:
select id from users where id in (1,2,3,4,5)
If the users table contains ids 1, 2, 3, this would return 1, 2, and 3. I want a query that would return 4 and 5. In other words, I don’t want the query to return any rows that exist in the table, I want to give it a list of numbers and get the values from that list that don’t appear in the table.
(updated to clarify question following several inapplicable answers)
Given the numbers are a fixed list. Quickest way I can think of is have a test table, populated with those numbers and do
untested select statement – but you will follow the princpal.
Then you’ll get back all the numbers that dont have a matching user.id and so can fill in the holes..