1.基本语法是: select ... from <TableName> where <Conditional-1> start with <Conditi
select ... from <TableName>
where <Conditional-1>
start with <Conditional-2>
connect by <Conditional-3>;
//<Conditional-1>:过滤条件,用于对返回的所有记录进行过滤。
//<Conditional-2>:查询结果重起始根结点的限定条件。
//<Conditional-3>:连接条件
//如果connect by prior中的prior被省略,则查询将不进行深层递归。
select t.* from s_menu t start with t.id='510' connect by prior t.fid = t.id
select t.* from s_menu t start with t.id='510' connect by prior t.fid = t.id
select t.* from s_menu t start with t.id='001' connect by prior t.id = t.fid
select t.* from s_menu t start with t.id='001' connect by prior t.id = t.fid
select t.id,t.name,fid,substr(sys_connect_by_path(NAME,'->'),3) menu_path
from s_menu t start with t.name = '系统功能' connect by prior t.id = t.fid order by t.id
select t.id,lpad('|-',(level-1)*4,'|-')||lpad('『',2)||t.name||rpad('』',2) as newname
from s_menu t connect by prior t.id=t.fid start with t.id='-1'
向上递归和向下递归的关键就是最后一个条件,父ID等于ID则向上递归,反之向下递归。
参考:Http://www.cnblogs.com/wanghonghu/arcHive/2012/08/31/2665945.html
--结束END--
本文标题: oralce递归查询
本文链接: https://www.lsjlt.com/news/43995.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-28
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0