I've got several tables that reference my "Images" table.
There are a load of records in my Images table that I know can be deleted - they're not referenced by any other table.
I want to get a list of all those images.
If I do this (taking an image ID that I suspect to be unused):
Code:
SELECT idCards FROM Cards WHERE idImages = 71;
SELECT idGifts FROM Gifts WHERE idImages = 71;
SELECT idUsers FROM Users WHERE idImages = 71;
...none of those queries return any rows. Which is good.
But if I then do this:
Code:
SELECT idImages FROM Images
WHERE 1=1
AND idImages NOT IN (SELECT idImages FROM cg_Cards)
AND idImages NOT IN (SELECT idImages FROM cg_Gifts)
AND idImages NOT IN (SELECT idImages FROM cg_Users)
That returns no rows either. Which, to me, makes no sense. If it's not in
any of the rows, it must be in
none of the rows.
Where am I going wrong?
