Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

x match data in 2 tables

Status
Not open for further replies.

JONBOY74

Technical User
Sep 11, 2001
36
US
Morning

Sorry if this question is a bit simply for the group, but I'm new to this.

I have 2 tables (TABLE A & TABLE B) both have the same columns etc but TABLE A has more rows (newer information).

What I'm trying to do is X-match the 2 tables and select all the rows that aren't in the table B but are in Table A

I've tried a number of select & where combination but I can't seem to work it out

Please Help

Many Thanks

Jon
 

For rows not in B but in A, with relation:

(Option 1)

SELECT *
FROM tableA
WHERE NOT EXISTS
( SELECT null
FROM tableB
WHERE tableB.col1 = tableA.col1
AND ... other related columns );


Or, a direct approach, this is a minus of the tables. This will display all rows (based on all cols) not in B but in A:

(Option 2)

SELECT *
FROM tableA
MINUS
SELECT *
FROM tableB;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top