原文 https://blog.csdn.net/qq_41080850/article/details/84648897 最后
select * from student where sid in
(select sid from
(select sid,cid from grade where sid in
(select sid from grade where sid !='06' group by sid
having count(*)=(select count(*) from grade where sid='06' group by sid))) as t1
inner join (select cid from grade where sid='06') as t2
on t1.cid = t2.cid
group by t1.sid
having count(*)=(select count(*) from grade where sid='06'));
这是原文最后的另一种求法,最后一句 为什么不可以改成 having count(cid)=(select count(*) from grade where sid='06'));
其他的都可以将 (*)换成(cid)
另外 用 on t1.cid = t2.cid 的原因是因为固定课程吗?这里用cid相同有点懂又有点不懂。