JOIN

0001-01-01

What is an SQL JOIN?

Forget the set-theory Venn diagrams. A JOIN composes two collections of objects into a new collection that has the properties of both.

0001-01-01

JOIN Output Cardinality: Why Your Row Counts Surprise You

A JOIN does not just combine tables — it multiplies rows. One-to-many joins inflate counts silently, and aggregate queries over joined data produce wrong results unless you account for it.

0001-01-01

LATERAL JOIN for Top-N Per Group

LATERAL lets the right-hand subquery reference columns from the left side — enabling top-N per group in a single scan without window functions and outer filters.

0001-01-01

The JOIN That Silently Loses Rows

The most common AI SQL mistake: a LEFT JOIN paired with a WHERE clause that filters on the right-side table, silently turning an outer join into an inner join and dropping the rows you asked for.

0001-01-01

COUNT(*) After a JOIN Counts Rows, Not Things

After a JOIN, COUNT(*) counts the rows in the intermediate result — which is not the same as counting the distinct entities you care about. The wrong number is plausible, which makes it dangerous.