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.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-08-08 : 07:42:13
|
Sujit writes "I have a table 'tblClassTeacher' which relates a Class [ClassId] to one or many Teachers [TeacherId]. When given some TeacherIds as input, I want to be able to find out which Classes are common to those. e.g. ClassId TeacherId---------------------------------- 1 1 1 2 1 3 2 2 2 3 4 3 5 4----------------------------------From above table, if input teachers are [2,3], I should be able to get classes 1 & 2. Input teacherId String may vary.Can it be done in one single Sql Statement?Thank you.Sujit." |
|
KenW
Constraint Violating Yak Guru
391 Posts |
Posted - 2006-08-08 : 12:49:07
|
Sujit,SELECT ClassID FROM tblClassTeacher WHERE TeacherID IN ( 2, 3 ) Ken |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|