首页 > 数据库技术 > 详细

oracle遍历树

时间:2016-08-23 16:55:07      阅读:269      评论:0      收藏:0      [点我收藏+]
1:首先数据库中表必须是树形结构的
2:super_department_id  department_id 的父节点编号
3:以下语句的执行结果是:department_id = 88 所有字节点及子子节点的记录
 
select * from pub_department a start with a.department_id = 88 connect by prior a.department_id = a.super_department_id

 

 

 

遍历此节点到祖先节点:

   select * from tree t  connect by prior t.parent= t.child start with t.child=‘001190360‘

遍历此节点到孙子节点:

   select * from tree t  connect by priort.child =t.parent start with t.child=‘001190360‘

oracle遍历树

原文:http://www.cnblogs.com/argus-agent/p/5799772.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!