递归取到以ID为parent的数据 select id from table start with id = 10000 connect by prior id=parent;递归取到以ID为son的数据 select id from table start with id = 10000 connect by prior parent=id
没可能用一条SQL语句查出所有的节点信息,以前有类似的提问。
我这样写,好像是可以了 select * from table start with parent is null --parent null表示根节点 connect by prior id=parent ORDER SIBLINGS BY id;
SELECT SYS_CONNECT_BY_PATH(REGION, '/') FROM table START WITH PRIOR is not null CONNECT BY PRIOR id=parent 层次就更清楚了
select id
from table
start with id = 10000
connect by prior id=parent;递归取到以ID为son的数据
select id
from table
start with id = 10000
connect by prior parent=id
select * from table
start with parent is null --parent null表示根节点
connect by prior id=parent ORDER SIBLINGS BY id;
FROM table
START WITH PRIOR is not null
CONNECT BY PRIOR id=parent
层次就更清楚了