当前位置:首页 > 课程 > 正文

查询选修了某个课程的学生姓名

  • 课程
  • 2024-09-18 00:08:15
  • 4841
本文目录一览壹、在数据库中怎么查阅选修了一号课程的同学姓名selectnamefromcoursewherecoursename="CourseNo.1"
其中“course”是表名称 贰、用sql语句查询选修了3门及以上课程的学生学号,姓名,选修的课程数=3

叁、查询选修了全部课程的学生的姓名,用两种查询语句表示你可以这样想!--学生名单;课程表;SC选课列表;
--Sno学生ID;
方法一:
selectSname
fromstudent
whereSnoIN(selectSno
fromSC
groupbySno
havingcount(*)=(selectcount(*)fromcourse))
方法二:
selectSname
fromstudent--学生表
whereNOTexists(select*
fromcourse--课程表
whereNOTexists(select*
fromSC
where--课程表
Sno=student.sno
andcno=Course.Cno))