Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query Help

Status
Not open for further replies.

jonnyk

Programmer
Jan 11, 2001
19
GB
I need to find all records from one table that dont have an entry in another table.
Is there a SQL staement that will do this for me?
IE All customers that have no orders
 
Hi,

Try this query...


SELECT *
FROM Customers
WHERE NOT EXISTS
(SELECT customerid
FROM orders
WHERE customerid = customers.customerid)


Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top