我有下表:示例: 节点:
id_node id_parent
--------------------
1 3
3 2
2 -1
我想在其他表中插入下降水平。例如:
id_node id_parent level
-------------------------
1 3 1
3 2 1
1 2 2
答案 0 :(得分:1)
应该是这样的:
SELECT id_node, id_parent, level
FROM nodes
START WITH id_parent = -1
CONNECT BY PRIOR id_node = id_parent