日期:2014-05-16  浏览次数:20441 次

orace 查找叶子结点的所有父节点
select  colunmnid,connect_by_root(colunmnid) precolumnid
from Test
WHERE precolumnid IS NOT null
connect by  prior colunmnid=  precolumnid
order by 1,2

Create Table Test(colunmnid Integer,precolumnid Integer)
Insert Into Test Values(0,Null);
Insert Into Test Values(2,0);
Insert Into Test Values(3,0);
Insert Into Test Values(4,2);
Insert Into Test Values(6,2);
Insert Into Test Values(7,3);
Insert Into Test Values(8,3);
Insert Into Test Values(9,4);

select * from test