为什么Oracle SQL在一个连接中神秘地解决了歧义,而在其他连接中却没有

And*_*uta 3 sql oracle ambiguity oracle10g

我是Oracle 10g用户.我不得不写一些SQL查询,并发现了一个神秘的(我看到它)行为.让我们假设我们有一个表,它可以加入某种简单的两级树结构.下一个查询给出了"歧义错误",这是预期的:

select title
  from table1
    left join table1 on condition
Run Code Online (Sandbox Code Playgroud)

但如果我要在连接中再添加一个表,那么歧义问题就会消失:

select title
  from table1
    join table2 on other_condition
    left join table1 on condition
Run Code Online (Sandbox Code Playgroud)

对此有何解释?我完全想念它......完整的测试用例可以在http://pastebin.com/webf513w找到

Jef*_*emp 5

对于第三个查询,Oracle 10g从第二个TestTable1(别名TestTable1_2)返回field3.这似乎是一个错误,似乎已经修复了11克.

测试用例:

INSERT INTO TestTable1 VALUES (1,2,3,NULL);
INSERT INTO TestTable1 VALUES (2,5,6,1);
INSERT INTO TestTable2 VALUES (5,6,7);
INSERT INTO TestTable2 VALUES (2,20,30);

SELECT field3
FROM TestTable1
join TestTable2 ON TestTable1.field1 = TestTable2.field1
left join TestTable1 TestTable1_2 ON TestTable1.self_ref = TestTable1_2.id;

FIELD3
======
3
(null)

SELECT TestTable1.field3, TestTable2.field3, TestTable1_2.field3
FROM TestTable1
join TestTable2 ON TestTable1.field1 = TestTable2.field1
left join TestTable1 TestTable1_2 ON TestTable1.self_ref = TestTable1_2.id;

FIELD3 FIELD3_1 FIELD3_2
====== ======== ========
6      7        3
3      30       (null)
Run Code Online (Sandbox Code Playgroud)