Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

union query question (maybe!) 1

Status
Not open for further replies.

danwand

Programmer
Jun 8, 2003
100
GB
Hi,

I have 2 tables with the following fields:

tblStaffDetails tblTrainingMeetings

StaffID (primary key) StaffID (primary key)
FName TrainID (primary key)
MName
LName
Address
etc...

I need a query that shows all staff members from tblStaffDetails who do do yet have a record in tblTrainMeetings.

Any help would be appreciated
thanks

Dan
 
who do have a record?

first, the trainingmeetings should be the staffid as a foreign key not primary.

Then - just do a query, add both tables in the design, connect the staffid and take a look. You can make it count or whatever.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
danwand,

Something like this.. maybe..

Code:
SELECT * FROM tblStaffDetails WHERE StaffID NOT IN (select StaffID from tblTrainingMeetings );

Hope this helps...


 
ahhh.

I didn't realize you wanted not in. Hitech has a good suggestion. If you want 2 full suggestions. you can do mine too and then just make it a group by, and make .tbltrainingmeetings.staffid a where and put is null in the criteria of the staffid. of the tbltrainingmeetings

misscrf

It is never too late to become what you could have been ~ George Eliot
 
SELECT D.*
FROM tblStaffDetails D LEFT JOIN tblTrainingMeetings M On D.StaffID = M.StaffID
WHERE M.StaffID Is Null;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
thanks hitechUser that worked fine

much appreciated

Dan
 
Thank HitechUser
for this valuable post!


star for you hitech!

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top