In PostgreSQL 18, table emp has 3 rows with dept_id values 10, 20 and NULL, and table dept_null has exactly one row whose id is NULL. How many rows does SELECT * FROM emp e JOIN dept_null d ON d.id = e.dept_id; return?
Explanation
A pair of rows matches only when the ON expression evaluates to true, and NULL = NULL evaluates to null, so the null dept_id never pairs with the null id. Answering 1 reads the join as matching identical values; writing ON d.id IS NOT DISTINCT FROM e.dept_id is what produces that row.