This SQL joins reference explains the join types used to combine rows from two or more tables — INNER, LEFT, RIGHT, FULL OUTER, CROSS and SELF joins.
| Join type | Returns |
|---|---|
| INNER JOIN | Only rows with a match in both tables |
| LEFT JOIN | All rows from the left table + matched right (NULL if none) |
| RIGHT JOIN | All rows from the right table + matched left |
| FULL OUTER JOIN | All rows from both tables, matched where possible |
| CROSS JOIN | Every combination of both tables (Cartesian product) |
| SELF JOIN | A table joined to itself |
Example
SELECT * FROM orders o INNER JOIN customers c ON o.customer_id = c.id; — returns orders that have a matching customer.