Sir, I now doing the joining of Two table in SQL Server.
My Tables are:-1. tbl_Subject(subjectId(pk),subjectName,teacherId(fk)),2.tbl_Teacher(teacherId(pk),teacherName)
There are 10 subjects with subjectId:-1.Malayalam,2.English,3.Hindi
Teacher with teacherId:-1.Mahesh,2.Hameed,3.Rao,4.Jasni
in this Mahesh teaching Hindi and English,
The question is :- find out the teacher teaching more than one subject?
I want your help in this problem. send me the right code.
Joins Two Table in SQL Server
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Pankaj PandeyRank #642 · 3.7K reputationPosted Jun 4, 2013, 10:07 PM EDT
IF YOU WANT TO SHOW DETAIL OF TEACHER WHO TEACH MORE THEN ONE SUBJECT THEN TRY THIS QUERY.
FOR ANY...
Sunny SharmaRank #223 · 11.1K reputationPosted Jun 4, 2013, 9:58 PM EDT
use the below query
------------------------------
SELECT teacherName
FROM tbl_Teacher a
INNER JOIN
tbl_Subject b
ON
a.teacherId=b.teacherId
GROUP BY teacherName HAVING COUNT(subjectName)>1
------------------------------
Mark it as answer if it helps!
Cheers.
Bineesh ViswanathRank #1,681 · 907 reputationPosted Jun 4, 2013, 10:51 PM EDT