With an outer join such as LEFT OUTER JOIN, we typically want all the records from the left table and records from right table that satisfy the join condition. However, if we include any field from the right table in the where clause, the join becomes an INNER JOIN for the following reason:
- Records from the left table that don’t find a match in the right table will have
NULLvalues in the fields from the right table - Comparing
NULLto any value results inNULL - Because
WHEREonly returns records that evaluate totrueand discard records that evaluates to eitherfalseorNULL - Therefore, records with
NULLvalues will be excluded. This means only the join becomesINNER JOIN
The above works the same for any form of OUTER JOIN.
To work around this, add the predicate to join statement after ON clause.