I have the following query (simplified) on MS Access:
SELECT * FROM table1 WHERE table1.ID NOT IN (SELECT DISTINCT table1id FROM table2);
My problem is it doesn’t work, but these two ones work:
SELECT * FROM table1 WHERE table1.ID IN (SELECT DISTINCT table1id FROM table2);
SELECT * FROM table1 WHERE table1.ID NOT IN (2, 3);
The first one simply returns me an empty set, while I know I have records on table1 with ids ranging from 1 to 9, and only 2 and 3 are use on table 2.
Any help?
Generally, the problem with IN and NOT in has to do with NULLs in the subselect. Try this and see if it works: