Bird
0
0

You have two tables: Students and Exams. You want to list all exams and include student names if available. Which JOIN should you use?

hard📝 Application Q8 of 15
SQL - LEFT and RIGHT JOIN
You have two tables: Students and Exams. You want to list all exams and include student names if available. Which JOIN should you use?
ALEFT JOIN Exams ON Students.id = Exams.student_id
BRIGHT JOIN Students ON Exams.student_id = Students.id
CLEFT JOIN Students ON Exams.student_id = Students.id
DFULL JOIN Exams ON Students.id = Exams.student_id
Step-by-Step Solution
Solution:
  1. Step 1: Identify which table to keep all rows from

    We want all exams listed, so Exams is the table to keep all rows from.
  2. Step 2: Choose JOIN type to keep all Exams rows

    LEFT JOIN keeps all rows from the left table. To keep all Exams, Exams must be the left table.
  3. Step 3: Match correct syntax

    LEFT JOIN Students ON Exams.student_id = Students.id means FROM Exams LEFT JOIN Students, which is correct.
  4. Final Answer:

    LEFT JOIN Students ON Exams.student_id = Students.id -> Option C
  5. Quick Check:

    Keep all Exams rows = LEFT JOIN with Exams as left table [OK]
Quick Trick: Keep all rows from Exams (left table) use LEFT JOIN [OK]
Common Mistakes:
MISTAKES
  • Using RIGHT JOIN with Exams as left table incorrectly
  • Confusing which table is left or right
  • Choosing LEFT JOIN when RIGHT JOIN is needed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes