
Answer-first summary for fast verification
Answer: LEFT JOIN
The correct answer is **LEFT JOIN** because it returns all records from the left table (students), and the matched records from the right table (enrollments). If there is no match, the result is NULL on the side of the right table. This explains why John (U0003) shows NULL for course_id, indicating he is not enrolled in any course. Reference: [Databricks SQL Join Syntax](https://docs.databricks.com/sql/language-manual/sql-ref-syntax-qry-select-join.html)
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
Given the following two tables, which JOIN operation should be used in the blank to ensure the query returns all students, including those not enrolled in any course, with their course_id if available?
SELECT students.name, students.age, enrollments.course_id
FROM students
_____________ enrollments
ON students.student_id = enrollments.student_id
SELECT students.name, students.age, enrollments.course_id
FROM students
_____________ enrollments
ON students.student_id = enrollments.student_id
A
RIGHT JOIN
B
INNER JOIN
C
LEFT JOIN
D
ANTI JOIN
E
CROSS JOIN