Bird
0
0

Given two tables:

medium📝 query result Q13 of 15
SQL - INNER JOIN
Given two tables:
Students(id, name)
Grades(student_id, grade)
What will this query return?
SELECT Students.name, Grades.grade FROM Students JOIN Grades ON Students.id = Grades.student_id;
AAn error because of missing WHERE clause
BAll students with NULL grades included
COnly grades without student names
DA list of student names with their grades where student IDs match
Step-by-Step Solution
Solution:
  1. Step 1: Understand INNER JOIN behavior

    JOIN without specifying LEFT or RIGHT is INNER JOIN, which returns rows with matching keys in both tables.
  2. Step 2: Analyze the query result

    The query returns student names and grades only where Students.id matches Grades.student_id.
  3. Final Answer:

    A list of student names with their grades where student IDs match -> Option D
  4. Quick Check:

    INNER JOIN returns matching rows = A list of student names with their grades where student IDs match [OK]
Quick Trick: INNER JOIN returns only matching rows from both tables [OK]
Common Mistakes:
MISTAKES
  • Expecting all students even without grades
  • Thinking JOIN returns unmatched rows
  • Assuming WHERE is needed for JOIN condition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes