Bird
0
0

Given the tables:

medium📝 query result Q4 of 15
SQL - INNER JOIN
Given the tables:

Students
ID | Name
1 | John
2 | Emma
3 | Mike

Scores
StudentID | Score
1 | 85
2 | 90
4 | 75

What will be the result of this query?
SELECT Students.Name, Scores.Score FROM Students INNER JOIN Scores ON Students.ID = Scores.StudentID;
AJohn 85<br>Emma 90<br>Mike 75
BJohn 85<br>Emma 90<br>Mike NULL
CJohn 85<br>Emma 90<br>Mike 75<br>NULL 75
DJohn 85<br>Emma 90
Step-by-Step Solution
Solution:
  1. Step 1: Identify matching rows by INNER JOIN

    INNER JOIN returns rows where Students.ID matches Scores.StudentID: IDs 1 and 2.
  2. Step 2: Check unmatched rows

    Student ID 3 (Mike) has no matching Score, so excluded; Score with StudentID 4 excluded.
  3. Final Answer:

    John 85
    Emma 90
    -> Option D
  4. Quick Check:

    INNER JOIN excludes unmatched rows [OK]
Quick Trick: INNER JOIN returns only rows with matching keys in both tables [OK]
Common Mistakes:
MISTAKES
  • Expecting unmatched rows to appear with NULL
  • Confusing INNER JOIN with LEFT JOIN
  • Including rows with no match

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes