I have the follow table: example: nodes:
id_node id_parent
--------------------
1 3
3 2
2 -1
I want to insert in other table the level of descent. For example:
ancestor:
id_node id_parent level
-------------------------
1 开发者_C百科 3 1
3 2 1
1 2 2
Should be something like this:
SELECT id_node, id_parent, level
FROM nodes
START WITH id_parent = -1
CONNECT BY PRIOR id_node = id_parent
精彩评论