We help IT Professionals succeed at work.

Query Question

I have the following table A, together the 2 columns make a key:
CardNumber
Profile

Then I have table B which is a subset of table A same columns.

How can I get the values which are in table A which are not in table B?  I need all the card/profile combinations in A which are not in B.

Thanks
Comment
Watch Question

Top Expert 2008

Commented:
try this
SELECT tableA.* FROM tableA LEFT JOIN tableB ON (tableA.CardNumber=tableB.CardNumber AND tableA.Profile=tableB.Profile) WHERE
(tableB.CardNumber IS NULL OR tableB.Profile IS NULL)

Open in new window

Senior Web Developer
CERTIFIED EXPERT
Commented:
This is more simpler using EXCEPT command which eliminates records from the second query.

(SELECT     CardNumber, Profile
FROM         TableA)
EXCEPT
(SELECT     CardNumber, Profile
FROM         Table2)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.