Select item from one table not in another

M

mommio2

Hello, I am desperate to find out how to do this either with SQL or in
design view in Access 2003. Any help you could give me would be REALLY
appreciated!

I have 2 tables, Customer & Order.

Customer has a CustId
Order has an OrderId and a CustId

If a customer has placed an order at any time, he/she will be listed in the
CustID field in the order table, thus he may be in there multiple times.

I need to find the SQL (or a way in design view in Access 2003) to list all
customers who are NOT in the Order table.

THANKS!!!
Mommio2
 
S

Sylvain Lafontaine

The easiest way to do this would be to use the NOT EXISTS () statement;
something like:

Select C.*
From Customer as C
Where Not Exists (Select * From Order as O where O.CustId = C.CustId)

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain2009 sylvainlafontaine com (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)
 

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