Weird SQL Server view definition

别来无恙 提交于 2019-11-29 15:16:24
SELECT ...
FROM   dbo.viewFirst vf
       INNER JOIN dbo.Table1 t1
         ON vf.MVOID = t1.MVOID
            AND vf.ValidFrom = t1.ValidFrom
       LEFT OUTER JOIN dbo.Table2 t2
                       RIGHT OUTER JOIN dbo.Table3 t3
                         ON t2.OID = t3.FKOID
                       LEFT OUTER JOIN dbo.Table4 t4
                         ON t3.ZVOID = t4.OID
                       LEFT OUTER JOIN dbo.Table5 t5
                                       INNER JOIN dbo.Table4 t6
                                         ON t5.OID = t6.BCOID
                         ON t4.ZVOID = t5.OID
         ON t2.AddressOID = t4.OID  

This syntax is covered in chapter 7 of Inside SQL Server 2008 T-SQL Querying or see this article by Itzik Ben Gan and the follow up letter by Lubor Kollar

Having the ON clause for t2.AddressOID = t4.OID last for example means that the JOIN of t2 logically happens last. i.e the other joins are logically processed first then the LEFT JOIN happens against the result of those Joins.

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