this is tricky, because it involves a 5-way join, from one many-to-many (job profiles to knowhows) to another (knowhows to employees)
so for a moment, let's focus on just one -- knowhows to employees
the general strategy is to join each employee to all of her knowhows
Code:
select K.Name as KnowHow
, E.Name as Employee
from tKnowHow as K
inner
join tLinkEmpKnow as EK
on K.ID
= EK.KnowHowID
inner
join tEmployees as E
on EK.EmployeeID
= E.ID
once you ensure this join is working correctly, what you do is specify the desired knowhows in the WHERE clause, then group on the employee and count to see how many different knowhows she has
Code:
select E.Name as Employee
from tKnowHow as K
inner
join tLinkEmpKnow as EK
on K.ID
= EK.KnowHowID
inner
join tEmployees as E
on EK.EmployeeID
= E.ID
where K.Name in ( 'HTML', 'CSS', 'SQL' )
group
by E.Name
having count(distinct K.ID) = 3
the HAVING clause here requires that each employee has all three of the knowhows which were filtered in the WHERE clause
you could even say HAVING count(distinct K.ID) >= 2 which would find employees whith at least two of the selected knowhows
finally, to finish the join, you can drive the specification of which knowhows are filtered for, by joining the K table to the PK table and the PK table to the P table, and specifying the JobName in the WHERE clause
rudy
SQL Consulting