oracle 树结构查询

SELECT RPAD(' ', 4 * (LEVEL-1), '--') || name as name,
CONNECT_BY_ROOT name "ROOT",
CONNECT_BY_ISLEAF "ISLEAF",
LEVEL,
t.*,
SYS_CONNECT_BY_PATH(t.name, '/') "PATH"

from sys_department t
START WITH T.DEPARTMENTID = 1
CONNECT BY NOCYCLE PRIOR T.Departmentid = T.PARENTDEPARTMENTID
order siblings by t.departmentid;


SELECT RPAD(' ', 2 * (LEVEL - 1), '-') || Tn_Id,
CONNECT_BY_ROOT Tn_Id "ROOT",
CONNECT_BY_ISLEAF "ISLEAF",
LEVEL,
t.*,
SYS_CONNECT_BY_PATH(t.Tn_Id, '/') "PATH"

from (
(SELECT c.tn_id, c.tn_name, c.parent_id, c.orders
FROM tree_node_c c
where c.proj_phase = 'PD'
and (c.view_mode = 2 or c.view_mode = 0) )
union
select d.tn_id, d.tn_name, d.parent_id, d.orders
from tree_node_d d
where d.proj_id = '15-B154C'
AND (d.view_mode = 2 or d.view_mode = 0)
and d.proj_phase = 'PD'

) t
START WITH T.Parent_Id = 'DP1_000'
CONNECT BY NOCYCLE PRIOR T.Tn_Id = T.PARENT_ID
order siblings by orders
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值