query to return only unique records from 2 tables?

R

ranfree

I have 2 tables (OLD and NEW) with identical formats, and I want to extract
only records where the ID is in the NEW table but is not in the OLD table.

for example:

OLD table:
ID fld1 fld2 fld3
1 any any any
3 any any any
5 any any any
6 any any any

NEW table
ID fld1 fld2 fld3
1 any any any
2 any any any
3 any any any
4 any any any
5 any any any
6 any any any
7 any any any

I want the following records returned:
ID fld1 fld2 fld3
2 any any any
4 any any any
7 any any any

Can you help me with a query or script to do this?

Thank you,
 
O

Ofer Cohen

You can use the Query Wizard to create an UnmatchRecord Query, that list all
the records in one table and not in the other one.

Something like

SELECT NewTableName.*
FROM NewTableName LEFT JOIN OldTableName ON NewTableName.ID= OldTableName.ID
WHERE OldTableName.ID Is Null
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top