SQL 练习22

  • 查询出只选修两门课程的学生学号和姓名
--方式1:

SELECT Student.SId,Sname from Student WHERE SId in (
	SELECT sid  from sc GROUP BY SId HAVING COUNT(cid)=2 )
	
--方式2

SELECT Student.SId,Sname from Student,
(SELECT sid  from sc GROUP BY SId HAVING COUNT(cid)=2) as t WHERE Student.sid = t.sid

image

posted @ 2021-08-20 15:29  弩哥++  阅读(32)  评论(0编辑  收藏  举报