Oracle子层次查询按父子树连接深度未知级别? 简单但我似乎无法使它工作......
Table ABC
ID parent_ID Name
1 0 Art
2 0 Home
3 0 Contact
4 0 Bob
5 0 Boo
6 0 Foo
7 2 FooBoo
8 5 Hoo
9 8 My
10 2 Rob
Order by Name Results wanted
Art
Home
** FooBoo
** Rob
Contact
Bob
Boo
** Hoo
** ** My
Foo
FooBoo
答案 0 :(得分:1)
SELECT NAME, id, parent_id, LEVEL
FROM ABC
START WITH id = 0
CONNECT BY PRIOR id = parent_id
ORDER SIBLINGS BY NAME;