SQL Code - Compare Tables

Arg81

Well-known member
Joined
Mar 11, 2005
Messages
949
Location
Midlands, UK
Programming Experience
1-3
Hey,

Wonder if someone can help.

I managed to do this ages ago but I've misplace the query.. :rolleyes:

TblCustomer - CustomerID, customerName.....etc

TblProducts - ProductId, CustomerID....etc


I need to run a query that will show ALL the customerID values THAT ARE NOT USED in the tblProducts table.

Trying to sort out the redundant customers, I did it last year some time but can't remember how!

Regards,
Luke
 
Try....
VB.NET:
Expand Collapse Copy
SELECT C.*
FROM tblCustomer C
LEFT JOIN tblProducts P
  ON C.CustomerID = P.CustomerID
WHERE P.ProductID IS NULL

-tg
 
Back
Top