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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting records based on course prerequisites 1

Status
Not open for further replies.

meumax

Programmer
Apr 13, 2002
38
0
0
AU
I have two tables. One containing records of training qualifications staff have received with a structure like:

StaffID | QualiicationID
1 | 1
1 | 2
1 | 26
2 | 1
2 | 2
3 | 1

And another showing the qualifications required to be eligible for a certain position with a structure like:

Position | fkQualificationID
boss | 1
boss | 2
boss | 26

So, to be eligible for the "boss" position, an employee would need qualifications 1,2 and 26 which would mean only employee "1" would be eligible.

Given a position, how can I select all staff from the staff qualifications table which have all the necessary qualifications for the position?
 
[tt]select staffid
from qualifications Q
inner
join staff S
on Q.fkQualificationID = S.QualificationID
where Position = 'boss'
group
by staffid
having count(*)
= ( select count(*)
from qualifications
where Position = 'boss' )[/tt]

rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top