我有2个表IndexTab,ChildNodes。 Index选项卡有一个名为“Index”的coljumn,它给出了唯一值
150
160
170
这些值被截断并在每次执行时随机填充。该表与下面的子表
相关+----+------------+--------+
| ID | ChildValue | Parent |
+----+------------+--------+
| 1 | Child 1 | 150 |
| 2 | Child 2 | 1 |
| 3 | Child 3 | 1 |
| 4 | Child 4 | 2 |
| 5 | Child 5 | 2 |
| 6 | Child 6 | 3 |
| 7 | Child 7 | 160 |
| 8 | Child 8 | 7 |
| 9 | Child 9 | 7 |
| 10 | Child 10 | 8 |
| 11 | Child 11 | 9 |
| 12 | Child 12 | 9 |
+----+------------+--------+
现在我想要分层查询,这可以用Correlation编写。下面是我想写的样本......
SELECT ChildValue, ID, Parent
FROM ChildNodes
START WITH ID = IndexTab.Index
CONNECT BY PRIOR ID = Parent
答案 0 :(得分:1)
目前尚不清楚你想得到什么。
我的假设是你需要这样的东西:
SELECT ChildValue, ID, Parent
FROM ChildNodes
START WITH Parent IN (select Index from IndexTab)
CONNECT BY PRIOR ID = Parent