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
 SQL Server Development (2000)
 Selecting Multiple records from a related table.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-06-19 : 16:21:21
Jason writes "I have 3 tables as follows:

-Users-
ID (PK)
UserName
Password

-Skills-
ID (PK)
SkillName
SkillCat

-UserSkills-
ID (PK)
SkillID (FK)
UserID (FK)


here is some sample date:

-Users-
1,jwhelan,password
2,bjones,password
3,suser,password

-skills-
1,ASP,Development
2,SQL,Development
3,VB,Development
4,HTML,Design

-UserSkills-
1,1,1
2,3,1
3,2,2
4,3,3
5,4,3
6,4,1


Here is my question:
The front end for this application is ASP, and the option will be given to select either users with All the skills selected in the search, or users with any of the skills selected in the search.

I have no problem with getting users with any of the skills selected, The problem lies when I try and get users with all the skills selected.

like: Select * from UsersSkills where skillid=1 and skillid=2 (Returns Nothing)

to get users that have any of the skills selected I just use:
Select * from UsersSkills where skillid in (1,2)
and that works fine.


OS: Windows 2000 SP2
Sql Server 2000

I hope I have made myself clear, please reply if you need any further explaination.

Thanks
Jason"
   

- Advertisement -