Link to home
Start Free TrialLog in
Avatar of kg6lfz
kg6lfz

asked on

how to delete records from tblA that do not belong to tblB

I have 2 tables, tblBuyer and tblItem.  Both have a field "Buyer".  I want to delete records from tblItem if tblItem.Buyer does not exist in tblBuyer.Buyer.  

Delete from tblItem - After that I am not sure how to limit records to be deleted.

Thank you very much in advance.  / hb
Avatar of Helen Feddema
Helen Feddema
Flag of United States of America image

First make a Find Unmatched query, using the Query Wizard, to select records in tblItem that don't have a matching record in tblBuyer.  Then make it into a make-table query and run it.  Make a Delete query with the table created by the make-table query and tblItem, linking on the appropriate key field.  This will delete the records that don't have a match.

You have to make a table to do this, because if you just use the Find Unmatched query in the Delete query, you will get a message that it is not updatable.
ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kg6lfz
kg6lfz

ASKER

It worked wonderful.  Thank you.