Solved

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

Posted on 2011-03-21
3
262 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:kg6lfz
3 Comments
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 35184706
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.
0
 
LVL 40

Accepted Solution

by:
Sharath earned 250 total points
ID: 35184795
try this.
Delete from tblItem where Buyer not in (select Buyer from tblBuyer);

Open in new window

0
 

Author Closing Comment

by:kg6lfz
ID: 35185027
It worked wonderful.  Thank you.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hit enter key to run macro 13 24
How to execute an access 2007 module from vb6 2 39
Delete Records on a Form in Microsoft Access 5 39
Progress bar in access form 11 25
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question