delete query

K

Kurt Neumann

access 2000, windows xp
i have two tables say, customers and orders with a one to many link of
invoice number
i wish to delete from customers all records with no orders.
i can do a select query with a null criteria in the invoice number in
orders to find all unmatched customers, but when i try to make this into a
delete query, i get a notice that i must select the table and i don't know
how to do that. any help.

ie, i want to delte from table 1 all records with no match in table 2.
thanks
khn
 
A

Allen Browne

Use a subquery in the WHERE clause.

Something like this:
DELETE FROM Customers
WHERE NOT EXISTS
(SELECT OrderID FROM Orders
WHERE Orders.CustomerID = Customers.CustomerID);
 

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