GUIDE深度 · Deep dive
SQL JOIN Types and Usage
JOIN combines tables on a key: INNER keeps matches, LEFT keeps all left rows. Put join conditions in ON and filters in WHERE; decide what one row means before GROUP BY.
Types
INNER JOIN: matches on both sides.
LEFT JOIN: keep all left rows; missing right values are NULL.
CROSS JOIN: Cartesian product.
Aggregation
JOIN can multiply rows.
COUNT(*) counts rows; COUNT(col) ignores NULL.
FAQ
ON vs WHERE?
ON controls the join; WHERE filters results, especially with LEFT JOIN.
Does join order matter?
Not logically; it can matter for performance.