[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2011-03-21
3
Medium Priority
?
269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 41

Accepted Solution

by:
Sharath earned 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

650 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