Is my understand of filtering joins using ON
vs. WHERE
correct?
WHERE
...will filter the result of the joined tables, meaning a LEFT JOIN
or RIGHT JOIN
won't display all records in the intended table because they will be filtered out even though the WHERE
filter might be on a field in the other table.
ON
...can be used as a filter for the table being joined. I used to think ON
was only used to compare fields between two tables when joining them, but it can also act like an isolated WHERE
for the specific table being joined.
None of this really matters when you are only joining two tables, but I have come to realize that understanding the difference is critical when doing very large joins across 3+ tables.