How to rewrite a query to find records that exist on 1 table and not on another table ?

I am developing an application in Access using Access as the front end and SQL Server as the back end
database.

The following query tells me the number of records where the CustomerNumber + OfficeNumber match
between 2 tables named tblCustomers and tblProducts:


select count(*)
FROM tblCustomersNew As C inner JOIN tblProductsNew As P
ON C.CustomerNumber=P.CustomerNumber AND C.OfficeNumber=P.OfficeNumber

Could you tell me how to rewrite this query to find any record(s) on the
tblProductsNew table and not on the tblCustomersNew table ?
zimmer9Asked:
Who is Participating?
 
RurneConnect With a Mentor Commented:
Use an outer join, then check for empty halves the outer join:

select count(*)
FROM tblCustomersNew As C RIGHT JOIN tblProductsNew As P
ON C.CustomerNumber=P.CustomerNumber AND C.OfficeNumber=P.OfficeNumber WHERE C.CustomerNumber IS NULL;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.