Bird
0
0

This SQL query is intended to find all courses taken by student with ID 3:

medium📝 Debug Q6 of 15
SQL - Table Relationships
This SQL query is intended to find all courses taken by student with ID 3:
SELECT c.Name FROM Course c JOIN StudentCourse sc ON c.ID = sc.CourseID WHERE sc.StudentID = 3;

But it returns no rows even though student 3 exists and has courses. What is the likely error?
AThe junction table has no matching records for student 3.
BThe WHERE clause filters on a non-existent student ID.
CThe join condition uses wrong columns.
DThe Course table has no matching course IDs.
Step-by-Step Solution
Solution:
  1. Step 1: Check join and filter logic

    The join and WHERE clause are correct for filtering courses by student ID.
  2. Step 2: Consider data in junction table

    If no rows return, likely the junction table lacks entries for student 3, even if student exists.
  3. Final Answer:

    The junction table has no matching records for student 3. -> Option A
  4. Quick Check:

    No junction records = no results [OK]
Quick Trick: No junction records means no join results [OK]
Common Mistakes:
MISTAKES
  • Assuming join condition is wrong
  • Assuming student ID does not exist
  • Blaming Course table for missing data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes