为什么 Oracle SQL 能够神秘地解决一个连接中的歧义性,而不能解决其他连接中的歧义性
我是 Oracle 10g 用户。我必须编写一些 SQL 查询,并发现了一个神秘的(正如我所看到的)行为。假设我们有一个表,它能够将自身连接成某种简单的两级树结构。下一个查询给出了“歧义错误”,这是预期的:
select title
from table1
left join table1 on condition
但是如果我向联接添加一个表,歧义问题就会消失:
select title
from table1
join table2 on other_condition
left join table1 on condition
对此的解释是什么?我完全想念它......完整的测试用例可以在 http://pastebin.com/webf513w 找到
I'm an Oracle 10g user. I had to write some SQL queries, and spotted a mysterious (as I see it) behaviour. Let's pretend we have a table, which is able to join itself in some kind of simple two-level tree structure. The next query gives me "ambiguity error", which is expected:
select title
from table1
left join table1 on condition
BUT if I would add one more table to the join, the ambiguity problem will simply go away:
select title
from table1
join table2 on other_condition
left join table1 on condition
What would be the explanation of this? I miss it completely... The full test case can be found at http://pastebin.com/webf513w
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于第三个查询,Oracle 10g 从第二个 TestTable1(别名 TestTable1_2)返回 field3。这似乎是一个错误,似乎已在 11g 中修复。
测试用例:
For the third query, Oracle 10g returns field3 from the second TestTable1 (alias TestTable1_2). This appears to be a bug, which seems to have been fixed in 11g.
Testcase: