查询学过学号为“1”同学所有课程的其他同学学号和姓名
1 回答
哈士奇WWW
TA贡献1799条经验 获得超6个赞
SELECT stu.Sid, stu.Sname FROM Student stu INNER JOIN SC score2
ON (stu.Sid = score2.Sid) WHERE score2.Cid IN (
SELECT Cid FROM SC score WHERE score.Sid = '1' )
GROUP BY stu.Sid, stu.Sname
HAVING COUNT(score2.Cid) = (
SELECT COUNT(1) FROM SC score WHERE score.Sid = '1' ) AND stu.Sid <> '1'
添加回答
举报
0/150
提交
取消