且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用JOIN时WHERE子句vs ON

更新时间:2023-10-23 14:19:40

不,查询优化器足够聪明,可以为两个示例选择相同的执行计划.

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

您可以使用SHOWPLAN检查执行计划.

You can use SHOWPLAN to check the execution plan.

尽管如此,您应该将所有联接连接放在ON子句上,并将所有限制都放在WHERE子句上.

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