What JOIN types are there, and how does INNER JOIN differ from LEFT JOIN?
Short answer
INNER JOIN keeps only row pairs that match in both tables; LEFT JOIN keeps every left row, with unmatched right columns as NULL. JOIN combines horizontally (adds columns); appending rows is UNION's job.
3 points to say:
INNERkeeps only rows matching in both tables;LEFTkeeps every left row, unmatched right side becomes NULL.- Anti-join:
LEFT JOIN ... WHERE right.id IS NULLorNOT EXISTS. - Self join for relations within one table (employee and manager); JOIN adds columns,
UNIONadds rows.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.