SELECT S FROM sc WHERE C in 
(SELECT C FROM sc WHERE S='01') 
GROUP BY S HAVING COUNT(S) =3

看到编号为1、2、3、4的同学选了与01号同学一致的课程

4,与student表进行连表查询,取出相关信息

SELECT a.* FROM
student a LEFT JOIN sc b
ON a.S = b.S WHERE b.S in (
SELECT S FROM sc WHERE C in 
(SELECT C FROM sc WHERE S='01') 
GROUP BY S HAVING COUNT(S) =3)
GROUP BY a.S