Hi I have this mysql table named student_subject_table:
+----+-------------+---------------------+
| id | student_id | subject |
+----+-------------+---------------------+
| 1 | 7 | math |
| 2 | 7 | physics |
| 3 | 7 | chemistry |
| 8 | 8 | math |
| 9 | 8 | physics |
| 10 | 8 | chemistry |
| 11 | 8 | biology |
+----+-------------+---------------------+
I am trying to get the ids of student those who have only math, physics and chemistry as subject.
I tried in clause:
select student_id
from student_subject table
where
subject in ('math', 'physics', 'chemistry')
GROUP BY (student_id)
As expected I am getting both 7 and 8 as student_id. In the above table I need only student_id = 7.
Is there any way in mysql I can do this ?
Please help.