Oracle 递归查询子节点和父节点

一、查询指定记录的父节点或子节点

1、查询父类以上所有数据

select  *  from plt_org_info start with id =47 connect by prior id = ParentsId

2、查询父类以下所有节点数据
select  *  from plt_org_info start with id =47 connect by prior ParentsId = id
二、查询所有叶子的父节点
Select DISTINCT * From VIEW_EJ_ZZJG START WITH JGLX='0207'
connect by prior FJGID=ZZJGID
ORDER BY PXH

 

原文地址:https://www.cnblogs.com/topboy168/p/15474007.html