Bird
0
0

Given these tables:

medium📝 query result Q5 of 15
SQL - Table Relationships
Given these tables:

Teacher: (1, 'Smith'), (2, 'Jones')
Course: (100, 'Math'), (200, 'Science')
TeacherCourse: (1, 100), (2, 100), (2, 200)

What will this query return?
SELECT c.Name FROM Course c JOIN TeacherCourse tc ON c.ID = tc.CourseID WHERE tc.TeacherID = 2;
AOnly Math
BMath and Science
COnly Science
DNo results
Step-by-Step Solution
Solution:
  1. Step 1: Understand the data

    Teacher 2 (Jones) teaches courses 100 (Math) and 200 (Science).
  2. Step 2: Analyze the query

    The query selects course names where TeacherID = 2 in TeacherCourse.
  3. Final Answer:

    Math and Science -> Option B
  4. Quick Check:

    Teacher 2 linked to both courses [OK]
Quick Trick: Join filters courses by teacher ID [OK]
Common Mistakes:
MISTAKES
  • Assuming only one course per teacher
  • Confusing TeacherID and CourseID
  • Ignoring join condition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes