Which join syntax is better?

我的未来我决定 提交于 2019-11-27 02:22:19

Well, "better" is subjective. There is some style here. But I'll address your questions directly.

  1. Both perform the same
  2. Both are ANSI-compliant.
  3. The problem with the first example is that

    • it is very easy to inadvertently derive the cross product (since it is easier to leave out join criteria)

    • it also becomes difficult to debug the join criteria as you add more and more tables to the join

    • since the old-style outer join (*=) syntax has been deprecated (it has long been documented to return incorrect results), when you need to introduce outer joins, you need to mix new style and old style joins ... why promote inconsistency?

    • while it's not exactly the authority on best practices, Microsoft recommends explicit INNER/OUTER JOIN syntax

    • with the latter method:

      • you are using consistent join syntax regardless of inner / outer
      • it is tougher (not impossible) to accidentally derive the cross product
      • isolating the join criteria from the filter criteria can make debugging easier

I wrote the post Kevin pointed to.

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