简体   繁体   中英

Oracle Hierarchical Query Connect by Parent Child Tree Unknown level deep?

Oracle Hierarchical Query Connect by Parent Child Tree Unknown level deep? Simple yet I cannot seem to make it work...


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
SELECT NAME, id, parent_id, LEVEL
FROM ABC
START WITH id = 0
CONNECT BY PRIOR id = parent_id
ORDER SIBLINGS BY NAME;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM