码迷,mamicode.com
首页 > 数据库 > 详细

Oracle 递归查询

时间:2015-09-02 00:21:58      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

 1 select a.accountcodeid, a.accountcode, a.accountcodename,
 2        SYS_CONNECT_BY_PATH(a.accountcodename, \) as fullname, a.parentcodeid, level
 3   from fm_accountcode a
 4  where a.accountcodeid >= 10000
 5  start with a.parentcodeid is null
 6 connect by prior a.accountcodeid = a.parentcodeid;
 7 
 8 select a.accountcodeid, a.accountcode, a.accountcodename,
 9        SYS_CONNECT_BY_PATH(a.accountcodename, \) as fullname,
10        a.parentcodeid
11   from fm_accountcode a
12  where a.accountcodeid > 10000
13    and connect_by_isleaf = 1
14  start with a.parentcodeid is null
15 connect by prior a.accountcodeid = a.parentcodeid;

oracle 中递归查询,对树型结构数据相当有用。

二者区别:上,所有数据,包含结构;下,所有末节点,包含结构,具体参见Oracle Document 11g。

Oracle 递归查询

标签:

原文地址:http://www.cnblogs.com/jekon/p/4776935.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!