Thursday, February 16, 2012

Checking for records where One value is NOT in the other?

I am trying to display results in which a value in my first result table is NOT contained in the second result table. Any idea on how to do this?.

SELECT CUSTOMERID, CUSTOMER FROM TABLE1

WHERE CUSTOMERID NOT IN TABLE2

Code Snippet

select c1.customerid, c1.customer

from table1 c1

left join table2 c2

on c1.customerid = c2.customerid

where c2.customerid is null

|||

Excellent, thanks

No comments:

Post a Comment