加入收藏 | 设为首页 | 会员中心 | 我要投稿 PHP编程网 - 湛江站长网 (https://www.0759zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

Oracle 树操作、递归查询(select…start with…connect by…prio

发布时间:2021-02-26 22:15:52 所属栏目:站长百科 来源:网络整理
导读:副标题#e# 一、Oracle中start with…connect by prior子句用法 connect by 是结构化查询中用到的,其基本语法是: select … from tablename start with 条件1 connect by 条件2 where 条件3; 例: select * from table start with org_id = ‘HBHqfWGWPy’
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 with tmp as(????select tb_menu.*,level lev????from tb_menu????start with parent is null????connect by parent = prior id)???? select b.*from tmp b,(select *????????????from tmp????????????where id = 21? and lev = 2) awhere b.lev = 1 ? union all ? select *from tmpwhere parent = (select distinct x.id????????????????from tmp x,--祖父?????????????????????tmp y,--父亲?????????????????????(select *??????????????????????from tmp??????????????????????where id = 21? and lev > 2) z --儿子????????????????where y.id = z.parent and x.id = y.parent);

(编辑:PHP编程网 - 湛江站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

8)、查询一个节点的父节点的的兄弟节点(伯父与叔父)。??????????