Let’s see an example retrieving the elements exist in Table A but not in Table B first.
In the last query, if you remove “where name is not null” clause, you won’t get expected result.
The reason is when comparing “Google” in Table A with Table B, the logic is equivalent to: “Google” <> “Bing” (TRUE) and “Google” <> “Yahoo” (TRUE) and “Google” <> null (UNKNOWN)
This leads to UNKNOWN finally in WHERE clause so nothing will return. In a word, just remember to
exclude NULL values when using NOT IN in WHERE clause.
Twitter · Facebook
Linkedin · Delicious
GitHub · Douban · Xbox Live