Bird
0
0

Given tables students (id, name) and grades (student_id, grade), what is the output of this query?

medium📝 query result Q13 of 15
SQL - INNER JOIN
Given tables students (id, name) and grades (student_id, grade), what is the output of this query?
SELECT s.name, g.grade FROM students s INNER JOIN grades g ON s.id = g.student_id;
ASyntax error due to missing alias
B[{"name": "Alice", "grade": "A"}, {"name": "Bob", "grade": "B"}]
C[{"student_id": 1, "grade": "A"}]
D[{"name": "Alice"}, {"grade": "A"}]
Step-by-Step Solution
Solution:
  1. Step 1: Understand the join condition

    The query joins students and grades where students.id matches grades.student_id.
  2. Step 2: Predict output rows

    Only students with matching grades appear, showing their name and grade as pairs.
  3. Final Answer:

    [{"name": "Alice", "grade": "A"}, {"name": "Bob", "grade": "B"}] -> Option B
  4. Quick Check:

    INNER JOIN returns matched student names with grades [OK]
Quick Trick: INNER JOIN shows matched rows with selected columns [OK]
Common Mistakes:
MISTAKES
  • Expecting unmatched rows to appear
  • Confusing alias names in SELECT
  • Assuming syntax error without cause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes