If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Comparison query
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 |
#2
|
|||
|
|||
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 "Su Cooper" escribió en el mensaje ... 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 |
#3
|
|||
|
|||
SELECT employeeId FROM tbl1 WHERE employeeId NOT IN (SELECT
DISTINCT employeeId FROM tbl2) Hope This Helps Gerald Stanley MCSD -----Original Message----- 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 . |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Taher | Setting Up & Running Reports | 1 | August 31st, 2004 09:07 PM | |
Display Parameter from Form on Report | sara | Setting Up & Running Reports | 10 | July 19th, 2004 04:54 PM |
Hidden files in Ms-Query cause ODBC connect errors or Query is wac | needyourhelp | General Discussion | 4 | July 12th, 2004 09:38 PM |
SELECT function in Query | alexparks | Running & Setting Up Queries | 9 | July 5th, 2004 11:31 AM |
Comparison Query | sh | Running & Setting Up Queries | 1 | June 24th, 2004 02:52 AM |