NEGATION JOIN IN SQL SERVER 2005
Today, I again come up with a very interesting problem with a very simple solution.
I have two tables, let me call the first table "A" and second table be "B". Both tables have a common column called EMAIL on which we can apply a join.
I want to select all those records which do not match Email Criteria in both tables, if this goes over your heads, let me tell rephrase this for you. It will be to SELECT ALL THOSE RECORDS WHERE A.EMAIL IS NOT EQUAL TO B.EMAIL
After careful analysis, here’s what comes in my mind and this might save your many mintues. Here’s the query…
SELECT A.Email FROM A WHERE A.Email NOT IN (SELECT B.Email FROM B)
I named it NEGATION JOIN :) Does this make sense for you people. Please do let me know if you figure out somthing is missing or wrong.
- Posted in: SQL Server