我正在处理一些遗留代码,我刚刚找到了一个带有两个“on”子句的连接......
select * from table
inner join table3
inner join table2 on table3.key = table2.fkey on table.key = table2.otherkey
Run Code Online (Sandbox Code Playgroud)
这种加入意味着什么?(它目前有效,所以这不是语法错误)
(编辑:修复了代码,缺少连接)
发布您的编辑只是了解隐式优先级的情况。
select * from table1
inner join table3
inner join table2 on table3.key = table2.fkey on table1.key = table2.otherkey
Run Code Online (Sandbox Code Playgroud)
是相同的
select * from
table1 inner join
(table3 inner join table2 on table3.key = table2.fkey)
on table1.key = table2.otherkey
Run Code Online (Sandbox Code Playgroud)
希望这更有意义。我在这里所做的只是添加括号。
从概念上讲,第一个连接table3totable2生成一个中间表,其中包含两者的所有列。table1然后使用您看到的第二个子句连接到此on。
| 归档时间: |
|
| 查看次数: |
210 次 |
| 最近记录: |