问题
Possible Duplicate:
Condition within JOIN or WHERE
Are the below 2 queries the same?
SELECT u.*
FROM User u
INNER JOIN Sales s ON (u.userId = s.userId)
WHERE
u.active = 1 AND
s.amount > 0 AND
s.status = 1
versus:
SELECT u.*
FROM User u
INNER JOIN Sales s ON
(u.userId = s.userId AND s.amount > 0 and s.status=1)
WHERE
u.active = 1
Are these 2 queries the same in terms of result set always? Performance considerations?
回答1:
The SQL Server Query Optimizer is smart enough to understand that this will do the same, so he will generate the same execution plan. That means you will get the same performance. To make it sure you can look at the Execution plan and compare them.
Check out Execution Plan Basics
来源:https://stackoverflow.com/questions/13145275/where-clause-versus-inner-join-statement-checks-are-they-the-same