Exam-style question
Try this first
Which SQL statement retrieves the names of students and the names of the courses they take from Student and Course tables linked by CourseID?.
- A.SELECT Student.Name, Course.CourseName FROM Student JOIN Course ON Student.CourseID = Course.CourseID;
- B.SELECT Student.Name, Course.CourseName FROM Student DELETE Course ON Student.CourseID = Course.CourseID;
- C.INSERT Student.Name, Course.CourseName INTO Student JOIN Course ON Student.CourseID = Course.CourseID;
- D.UPDATE Student.Name, Course.CourseName FROM Student JOIN Course ON Student.CourseID = Course.CourseID;
Model answer
What a good answer should say
- SELECT Student.Name, Course.CourseName FROM Student JOIN Course ON Student.CourseID = Course.CourseID;
Explanation
Why this works
SELECT retrieves the requested columns from both tables. JOIN combines the tables, and ON states that matching CourseID values link the rows.
Common mistake
No common mistake is linked to this question yet.
