SQL查詢選修了所有課程的學生姓名

2022-05-01 13:00:07 字數 459 閱讀 1368

select sname

from student

where not exists

(select *

from course

where not exists  

(select *

from sc

where sno =student.sno

and cno=course.cno);

最內部的 select * from sc wheresno=student.sno and cno = course.cno是查詢出所有已經選擇過課程的學生及相應課程,select

* from course where not exists 則是所有沒有被選擇的課程,

在這個基礎上的 select sname from student where  not exists 則是選取所有 沒有 未選擇課程的學生,即選修了所有課程的學生姓名。

SQL查詢選修了全部課程的學生姓名

1.select 2.sname 3.from 4.not exists 5.select from course where not exists 6.select from sc where sno student.sno and cno course.cno 對於這個題目我解釋一下 not e...

求出選修了所有課程的學生姓名

求出選修了所有課程的學生姓名 學生表 s sno int pk,sn varchar 8 sno為學號 sn為學生姓名。課程表 c cno int pk,cn varchar 50 cno為課程號,cn為課程名 選修表 sc sno int pk,cno int pk,score number 7,...

SQL查詢選修了全部課程的學生姓名解析

查詢選修le全部課程的學生姓名 select sname from student where not exists select from course where not exists select from sc where sno student.sno and cno course.cno...