SQL: INNER JOIN keeps matches, LEFT JOIN keeps the left side too

The difference only shows on rows with no match. INNER drops them; LEFT keeps them and fills the right-hand columns with NULL.

Code
SELECT c.name, o.id
  FROM customer c
  JOIN orders o ON o.customer_id = c.id;      -- customers WITH orders

SELECT c.name, o.id
  FROM customer c
  LEFT JOIN orders o ON o.customer_id = c.id; -- every customer
Output
INNER: Ann | 1
       Ann | 2
LEFT:  Ann | 1
       Ann | 2
       Bob | NULL     <- Bob has never ordered
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-25