WHERE Clause vs ON when using JOIN

inner-join, sql, sql-server, sql-server-2008-r2, t-sql

Solution

No, the query optimizer is smart enough to choose the same execution plan for both examples.

You can use `SHOWPLAN` to check the execution plan.

Nevertheless, you should put all join connection on the `ON` clause and all the restrictions on the `WHERE` clause.

Problem

Assuming that I have the following T-SQL code: ``` SELECT * FROM Foo f INNER JOIN Bar b ON b.BarId = f.BarId; WHERE b.IsApproved = 1; ``` The following one also returns the same set of rows: ``` SELECT * FROM Foo f INNER JOIN Bar b ON (b.IsApproved = 1) AND (b.BarId = f.BarId); ``` This might not be the best case sample here but is there any performance difference between these two?

Original source

Related problems