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 tableAnswer: 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…

  1. A.

    Both are the same

  2. B.

    INNER JOIN returns all rows from both tables, LEFT JOIN returns only matching rows

  3. 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

  4. 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:

  1. INNER JOIN example: SELECT * FROM A INNER JOIN B ON A.id = B.a_id; — returns only rows where A.id = B.a_id.

  2. 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.

Explore the full course: Deloitte Nla

Loading lesson…