Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Parent access based on all child records match

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-06-21 : 11:26:31
Muni writes "I have situation as follows. We have three tables.
1. Person - Id, Name and address
2. Skills - ID, Name
3. PersonSkills - personID, SkillID. One prson may have many skills. Each skill may be provided by many persons. Each person may have different set of skills.

Now the question is, I want a query, where by I would like to get the list of people who posseses a given list of skills (list may have varied numbers). The person should have all the skills as mentioned in the list.

Thanks
Muni"

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-06-21 : 11:33:56
This might work:

Select z.*
From Person as Z
Inner Join
(
Select PersonId
From PersonSkills as A
Inner Join (Select id From skills Where ','+id+',' like ','+@SkillListById+',') as B
On A.SkillId = B.Id
Group By PersonId
Having count(*) = (Select count(*) From skills Where ','+id+',' like ','+@SkillListById+',')
) as Y
On Z.id = y.PersonId


Corey
Go to Top of Page
   

- Advertisement -