SQL PSA: Never reference OUTER JOIN-ed tables in your WHERE clause

Never reference OUTER JOIN-ed tables in your WHERE clause. The exception is when you want to test if your outer join expression matched any rows at all; i.e., ¬†checking to see if the outer table’s primary key column is NULL. ¬†Otherwise, put any criteria on your outer tables within the join expression itself.

Full details: http://weblogs.sqlteam.com/jeffs/archive/2007/05/14/criteria-on-outer-joined-tables.aspx

Leave a Reply

Your email address will not be published. Required fields are marked *