Yesterday I was asked to check 2 tables for differences. First I tried it using the IN operaror:
SELECT * FROM Table1 where not(Table1.ID IN (SELECT Table2.ID
FROM Table2))
I knew there were supposed to be several differences between the tables, weirdly enough using this query I didn't find any.
Afterwards I tried it using a LEFT JOIN:
SELECT * FROM Table1 LEFT JOIN Table2
ON Table1.ID = Table2.ID
I made a view of this query, and when I checked for cases where Table2.ID was NULL I suddenly found my differences.
Personally I'm baffled by this. Does anyone here have an explanation for this?
Logically, at least that was what I thought, my 1st query should have sufficed, but it didn't yield anything.
Please help. This may sound like a newbie question, but I really would like to know what I did wrong.