SQL - LEFT and RIGHT JOINYou 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_idBRIGHT JOIN Students ON Exams.student_id = Students.idCLEFT JOIN Students ON Exams.student_id = Students.idDFULL JOIN Exams ON Students.id = Exams.student_idCheck Answer
Step-by-Step SolutionSolution:Step 1: Identify which table to keep all rows fromWe want all exams listed, so Exams is the table to keep all rows from.Step 2: Choose JOIN type to keep all Exams rowsLEFT JOIN keeps all rows from the left table. To keep all Exams, Exams must be the left table.Step 3: Match correct syntaxLEFT JOIN Students ON Exams.student_id = Students.id means FROM Exams LEFT JOIN Students, which is correct.Final Answer:LEFT JOIN Students ON Exams.student_id = Students.id -> Option CQuick 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:MISTAKESUsing RIGHT JOIN with Exams as left table incorrectlyConfusing which table is left or rightChoosing LEFT JOIN when RIGHT JOIN is needed
Master "LEFT and RIGHT JOIN" in SQL9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More SQL Quizzes Advanced Joins - CROSS JOIN cartesian product - Quiz 4medium Aggregate Functions - Combining multiple aggregates - Quiz 14medium INNER JOIN - INNER JOIN syntax - Quiz 8hard Set Operations - Why set operations are needed - Quiz 3easy Set Operations - Set operations with ORDER BY - Quiz 7medium Subqueries - Subquery vs JOIN performance trade-off - Quiz 3easy Table Constraints - Constraint naming conventions - Quiz 1easy Table Relationships - Foreign key linking mental model - Quiz 4medium Table Relationships - Referential integrity enforcement - Quiz 14medium Table Relationships - One-to-one relationship design - Quiz 4medium