What is the difference between "INNER JOIN" and "LEFT JOIN" in SQL?
2025
What is the difference between "INNER JOIN" and "LEFT JOIN" in SQL?
Answer: C. INNER JOIN returns only matching rows from both tables, LEFT JOIN returns all rows from the left table and matching rows from the right table — Answer: INNER JOIN returns only rows with matching values in both tables. LEFT JOIN returns all rows from the left table and matching rows from the right…
- A.
Both are the same
- B.
INNER JOIN returns all rows from both tables, LEFT JOIN returns only matching rows
- C.
INNER JOIN returns only matching rows from both tables, LEFT JOIN returns all rows from the left table and matching rows from the right table
- D.
LEFT JOIN can be used with a WHERE clause
Attempted by 1148 students.
Show answer & explanation
Correct answer: C
Answer: INNER JOIN returns only rows with matching values in both tables. LEFT JOIN returns all rows from the left table and matching rows from the right table; when there is no match, columns from the right table are NULL.
INNER JOIN: returns rows that satisfy the join condition in both tables. Rows without matches in either table are excluded.
LEFT JOIN: returns all rows from the left table. For rows without matching right-table rows, the right-table columns are NULL.
Example:
INNER JOIN example: SELECT * FROM A INNER JOIN B ON A.id = B.a_id; — returns only rows where A.id = B.a_id.
LEFT JOIN example: SELECT * FROM A LEFT JOIN B ON A.id = B.a_id; — returns every row from A; B columns are NULL when there is no matching B row.
Tip: Be careful when adding filters on columns from the right table in a WHERE clause after a LEFT JOIN; such filters can exclude rows with NULLs and effectively convert the result into an INNER JOIN. To preserve unmatched left-table rows, put conditions on the JOIN ... ON clause or explicitly allow NULLs in the WHERE clause.