Check the name of the student who took all the courses
: Student is the student table course is the timetable SC is the timetable
Select Sname
From student
Where NOT EXISTS
(SELECT *
From course
Where NOT EXISTS
(SELECT *
From SC
Where Sno =student.sno
and CNO=COURSE.CNO)
How to explain it? I just JoJo understand, but it is to explain to others do not understand. Hope the master to explain.
------Answer---------
------Other answers (10 points)---------
SELECT *
From course
Where NOT EXISTS
(SELECT *
From SC
Where Sno =student.sno
and CNO=COURSE.CNO)
This section calculates that a student has no selected courses
If the outer layer is added to a course that does not exist, there is no choice. That's the whole choice.
------Other answers (10 points)---------
-
SQL Code
-
--From the Inside Out analysis select * FROM Student--(3) Where NOT EXISTS (SELECT * FROM Course--(2) Where NOT EXISTS (SELECT * from S C WHERE Sno=student.sno--(1) and CNO=COURSE.CNO));--(1) Find all courses selected by a student select * from SC where Sno=student.sno--(2) Find this Students do not have elective courses select * FROM course C where NOT exists (SELECT * from SC where sno=student.sno and Cno=course.cno)--(3) Exclude this No Students taking all the courses
------Other answers (4 points)---------
Negative negative is positive, there is no one branch of no elective, that is, each branch elective
How do I find the name of the student who took all the courses? -ms-sqlserver/Application Examples