The SQL problem about student majoring courses
-
COURSE (CourseID, Cname, Ccredit) TEACHER (TeacherID, Tname, Toffice) STUDENT (StudentID, Sname, Sclass) TAKE_COURSES (CourseID, TeacherID, StudentID, Score, ClassRoom) Question: List all the name of students whose subjects are all past. The answer is: SELECT Sname FROM STUDENT WHERE NOT EXISTS( SELECT * FROM TAKE_COURSE WHERE TAKE_COURSE.StudentID= STUDENT.StudentID AND Score<60) I can't understand this sentence WHERE TAKE_COURSE.StudentID= STUDENT.StudentID AND Score<60) Can anyone please tell me how to resolve it? Thank you very much.
-
COURSE (CourseID, Cname, Ccredit) TEACHER (TeacherID, Tname, Toffice) STUDENT (StudentID, Sname, Sclass) TAKE_COURSES (CourseID, TeacherID, StudentID, Score, ClassRoom) Question: List all the name of students whose subjects are all past. The answer is: SELECT Sname FROM STUDENT WHERE NOT EXISTS( SELECT * FROM TAKE_COURSE WHERE TAKE_COURSE.StudentID= STUDENT.StudentID AND Score<60) I can't understand this sentence WHERE TAKE_COURSE.StudentID= STUDENT.StudentID AND Score<60) Can anyone please tell me how to resolve it? Thank you very much.
The statement selects all the records from table TAKE_COURSE, but filters them by the WHERE clause. Saying
WHERE NOT EXISTS
at the start, filters out those records where the StudentIDs match but the student score is less than 60. So you should end up with all students who have a score of 60 or greater. -
The statement selects all the records from table TAKE_COURSE, but filters them by the WHERE clause. Saying
WHERE NOT EXISTS
at the start, filters out those records where the StudentIDs match but the student score is less than 60. So you should end up with all students who have a score of 60 or greater.Yes. I understand it. Thank you very much.