Oracle实现树形结构sql

阅读更多


SELECT lpad('|-',(level-1)*4,' ')||lpad('『',2)||nodename||rpad('』',2) nodename
      FROM tbl_depttree
     CONNECT BY PRIOR nodeid = parentid
      START WITH parentid='0';


根据子节点 递归查询父节点 字符串

select substr(max(SYS_CONNECT_BY_PATH(dept_id,',')),2) as dn from org 
start WITH dept_id = 'a001' 
connect by  prior  super_id= dept_id

你可能感兴趣的:(oracle,sql,树形结构)