10 / 65 · 15 SQL & Database Testing · JOINs and Aggregation← prev⊞ allnext →☰ Read as one page
2.2JOIN Types
| JOIN Type | Returns | Use Case |
|---|---|---|
INNER JOIN |
Only matching rows from both tables | Orders with their items |
LEFT JOIN |
All rows from left, matching from right (NULL if none) | Users who may or may not have orders |
RIGHT JOIN |
All rows from right, matching from left (NULL if none) | Less common; same as LEFT JOIN with tables swapped |
FULL OUTER JOIN |
All rows from both tables | Orphaned records on both sides |
CROSS JOIN |
Every combination of rows | Generating test data combinations |
Visual Understanding
INNER JOIN: Only where both tables have matching data
LEFT JOIN: Everything from left table + matching from right
RIGHT JOIN: Everything from right table + matching from left
FULL OUTER: Everything from both, NULLs where no match