Comparison query

  • Thread starter Thread starter Su Cooper
  • Start date Start date
S

Su Cooper

Hi,

I'm new to queries and I'm trying to work out (without
success) how to do the following.

I have two tables:

tbl1 (the key of which is employeeID)
tbl2 (which has a field containing employeeID)

I want to create a query that lists all the employees from
tbl1 that do not have a record in tbl2. For info, an
employee could have many records in tbl2.

Please help!

Thanks

Joe
 
I think that could work:

SELECT tbl1.employeeID
FROM tbl1 LEFT JOIN tbl2 ON tbl1.employeeID = tbl2.employeeID
WHERE tbl2.employeeID Is Null;

You need a LEFT JOIN instead of an INNER JOIN.



Tonín
 
SELECT employeeId FROM tbl1 WHERE employeeId NOT IN (SELECT
DISTINCT employeeId FROM tbl2)

Hope This Helps
Gerald Stanley MCSD
 
Back
Top