Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. The SQL problem about student majoring courses

The SQL problem about student majoring courses

Scheduled Pinned Locked Moved Database
questiondatabasehelptutoriallearning
3 Posts 2 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tzungshian
    wrote on last edited by
    #1

    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.

    L 1 Reply Last reply
    0
    • T tzungshian

      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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.

      T 1 Reply Last reply
      0
      • L Lost User

        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.

        T Offline
        T Offline
        tzungshian
        wrote on last edited by
        #3

        Yes. I understand it. Thank you very much.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups