A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Comparison query



 
 
Thread Tools Display Modes
  #1  
Old August 31st, 2004, 09:45 PM
Su Cooper
external usenet poster
 
Posts: n/a
Default 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  
Old August 31st, 2004, 10:19 PM
Tonín
external usenet poster
 
Posts: n/a
Default

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  
Old August 31st, 2004, 10:33 PM
Gerald Stanley
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Print 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


All times are GMT +1. The time now is 10:07 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.