SQL查询所有上级/查询所有下级

--Oracle
--取所有的上级代码
select a.fnumber,a.fid,a.fParentID,level from T_ORG_Admin a 
start with a.fnumber = 'ZHPH' connect by prior a.FParentID = a.FID
order by level desc
--取所有的下级代码
select a.fnumber,a.fid,a.fParentID,level from T_ORG_Admin a 
start with a.fnumber = 'ZHPH' connect by prior a.FID = a.FParentID
order by level

你可能感兴趣的:(常用SQL笔记,金蝶,EAS,sql,oracle)