Where clause versus inner join statement checks, are they the same? [duplicate]

╄→гoц情女王★ 提交于 2019-12-11 03:24:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!