Excluding records where two tables have the same id

  • Thread starter Thread starter hopinion
  • Start date Start date
H

hopinion

Please help. I've been ramming my head on my keyboard from trying to
figure this problem out.


In a query, I have two tables. One of the tables (table 1) has a
uniqueidentifier and other fields regarding the characteristics of that
record. In the other table (table 2), I have another list of
uniqueidentifiers only. All unique identifiers in this table (table
2)are contained in the first table. My goal is to exclude any records
that are in table 2 from the list in table 1.


Thanks for any help anyone is able to provide!
 
SQL Statement would look like:

SELECT Table1.*
FROM Table1 LEFT JOIN Table2
ON Table1.UniqueIdentifier = Table2.UniqueIdentifier
WHERE Table2.UniqueIdentifier Is Null

If you are doing this in the query grid.
Add the two tables
Join them on the UniqueIdentifier.
Double Click on the join line
Select ALL RECORDS in Table1 and only ... in Table2

Add the fields you want to see from table1
Add the UniqueIdentifier from Table2
Uncheck "Show"
Enter IS NULL in the criteria (no quotes) for this field

Another option is to use the query wizard and build an UNMATCHED query. In the
database window, Click on the NEW button to get the choice of which wizard to use.
 
Back
Top