任何人都可以解释以下查询的行为:-
select level,t.*
from
( select 'one','two'from dual
union all
select 'one','two'from dual
) t
connect by level<=2
内部查询中有 2 行。我期待 4 行输出,但我得到 6 行输出。为什么会这样,这是如何工作的?
最佳答案
查询从您的两行之一开始并添加两行,然后继续第二行并再次添加两行。
像这样更改您的查询:
select level,t.*
from
( select 'one' from dual
union all
select 'two' from dual
) t
connect by level<=2;
这使得更容易看到发生了什么:
1 one
2 one
2 two
1 two
2 one
2 two
关于sql - Oracle SQL 按级别连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23992080/