It's a simple question, I'm getting started with SQL and I'm having a lot of problems with it.
I have TBL_SALES and TBL_CUSTOMERS. Both can be JOINed by the field CUSTOMER_ID. A customer may have a CUSTOMER_ID and have no entry on TBL_CUSTOMERS
I would like to FITER all entries on TBL_SALES that don't have an entry on TBL_CUSTOMERS.
Which I think it's the opposite of
SELECT UNIQUE TBL_SALES.CUSTOMER_ID, TBL_CUSTOMERS.CUSTOMER_ID
FROM TBL_SALES, TBL_CUSTOMERS
WHERE TBL_SALES.CUSTOMER_ID = TBL_CUSTOMERS.CUSTOMER_ID
Well... I can do that with a VBA code using SEEK and NOMATCH. But I know it's not productive. And if I try to use this code, it doesn't work:
SELECT UNIQUE TBL_SALES.CUSTOMER_ID, TBL_CUSTOMERS.CUSTOMER_ID
FROM TBL_SALES, TBL_CUSTOMERS
WHERE TBL_SALES.CUSTOMER_ID <> TBL_CUSTOMERS.CUSTOMER_ID
I realized that there must be a 'SEEK' command in SQL but I'm pretty sure that is a smarter way to run this query.