oracle查询父节点及其下所有子节点
1.我们的组织机构就是这种树形菜单的格式。
.
2.执行sql:
select
( select organization_name from SYS_ORGANIZATION where organization_id =x.organization_id) organization_name,
c.organization_id
from SYS_ORGANIZATION c, (select organization_id from SYS_ORGANIZATION where parent_id = '1') x where x.organization_id = c.organization_id or x.organization_id = c.parent_id start with c.organization_id =x.organization_id
connect by prior c.organization_id = c.parent_id
效果:

3.执行sql:
select organization_name,wmsys.wm_concat(organization_id ) organization_ids from
(select
( select organization_name from SYS_ORGANIZATION where organization_id =x.organization_id) organization_name,
c.organization_id
from SYS_ORGANIZATION c, (select organization_id from SYS_ORGANIZATION where parent_id = '1') x where x.organization_id = c.organization_id or x.organization_id = c.parent_id start with c.organization_id =x.organization_id
connect by prior c.organization_id = c.parent_id ) a group by organization_name
效果:

4.执行sql:
select a.organization_name,count(c.organization_id) sum from
(select organization_name,wmsys.wm_concat(organization_id ) organization_ids from
(select
( select organization_name from SYS_ORGANIZATION where organization_id =x.organization_id) organization_name,
c.organization_id
from SYS_ORGANIZATION c, (select organization_id from SYS_ORGANIZATION where parent_id = '1') x where x.organization_id = c.organization_id or x.organization_id = c.parent_id start with c.organization_id =x.organization_id
connect by prior c.organization_id = c.parent_id ) a group by organization_name ) a left join
(select c.clxxbh,c.organization_id from v_wfxx c left join BIZ_IMPORTANT_PLACES z on c.kkmc = z.place_name left join SYS_ORGANIZATION c on z.place_unit = c.organization_id) c
on instr(a.organization_ids,c.organization_id) > 0 group by a.organization_name
效果:

oracle查询父节点及其下所有子节点的更多相关文章
- postgre 查询同表中的,该节点写的所有子节点
SELECT catalogid, foldername, parentid, folderpath FROM public.ic_catalog; --查询同表中的,该节点写的所有子节点 WITH ...
- JQuery/JS插件 jsTree加载树,预先加载,初始化时加载前三级节点,当展开第三级节点时 就加载该节点下的所有子节点
jsTree加载树, 初始化时 加载前三级节点, 当展开第三级节点时 就加载该节点下的所有子节点 html: <!DOCTYPE html> <html> <head&g ...
- SQL查询父节点下的所有子节点(包括子节点下的子节点,无限子节点)
-->Title:Generating test data -->Author:wufeng4552 -->Date :2009-09-30 08:52:38 set nocount ...
- easyui Tree模拟级联勾选cascadeCheck,节点选择,父节点自动选中,节点取消,父节点自动取消选择,节点选择,所有子节点全部选择,节点取消,所有子节点全部取消勾选
最近项目中用到easyui tree,发现tree控件的cascadeCheck有些坑,不像miniui 的tree控件,级联勾选符合业务需求,所以就自己重新改写了onCheck事件,符合业务需求.网 ...
- mysql下如何删除本节点下的所有子节点小记
在开发过程中,经常会遇到树形结构的数据,在删除某个节点时候其所有的子节点都要被删除,可以使用如下方法: 1.添加记录该节点所有父节点的ID的字段(parent_ids),并用逗号隔开(一定是逗号),如 ...
- sqlserver查询指定树形结构的所有子节点
用标准sql的with实现递归查询(sql2005以上肯定支持,sql2000不清楚是否支持): with subqry(id,name,pid) as ( select id,name,pid fr ...
- Extjs4.x Ext.tree.Panel 遍历当前节点下的所有子节点
Ext.define('WMS.controller.Org', { extend: 'Ext.app.Controller', stores: ['OrgUser', 'OrgTree'], mod ...
- MySQL中进行树状所有子节点的查询 . mysql根据父id 查询所有的子id
在Oracle 中我们知道有一个 Hierarchical Queries 通过CONNECT BY 我们可以方便的查了所有当前节点下的所有子节点.但很遗憾,在MySQL的目前版本中还没有对应的功能. ...
- MySQL中进行树状所有子节点的查询
在Oracle 中我们知道有一个 Hierarchical Queries 通过CONNECT BY 我们可以方便的查了所有当前节点下的所有子节点.但很遗憾,在MySQL的目前版本中还没有对应的功能. ...
随机推荐
- git撤销提交(commit)
我们知道Git有三大区(工作区.暂存区.版本库)以及几个状态(untracked.unstaged.uncommited) 一.简介 Git 保存的不是文件的变化或者差异,而是一系列不同时刻的文件快照 ...
- 常见的NoSQL数据库
NoSQL数据库发展迅猛,据说现在已经有上百种NoSQL数据库了,下面来了解下常见的一些NoSQL数据库 先来看张表,了解下典型的NoSQL数据库的分类 临时性键值存储 永久性键值存储 面向文档的数据 ...
- Android - ANR小结
Application Not Responding 在Android上,如果你的应用程序有一段时间响应不够灵敏,系统会向用户显示一个对话框,这个对话框称作应用程序无响应(ANR:Applicatio ...
- php面向对象精要(3)
1,final关键字定义的方法,不能被重写 由于final修饰了show方法,子类中重写show方法会报错 <?php class MyClass { final function show() ...
- POJ3159(KB4-K 差分约束)
Candies Time Limit: 1500MS Memory Limit: 131072K Total Submissions: 33283 Accepted: 9334 Descrip ...
- 绘图:Matplotlib
用于绘制一些数据图,同学推荐的,挺好用.非常好的官网文档:http://matplotlib.org/contents.html 0. 安装 可以直接pip install,还有一些依赖就按照提示来吧 ...
- 使用PHP把图片上传到七牛
先从官网下载SDK,然后新建一个文件,里面包括上传,下载,删除 <?php header("Content-Type:text/html; charset=utf8"); r ...
- github 账号创建
1.注册 注册地址: https://github.com/join?source=header-home 2.建立组织 (1)点击头像旁边的"+",选择New organiz ...
- 【读书笔记】iOS-网络-测试与操纵网络流量
一,观测网络流量. 观测网络流量的行为叫做嗅探或数据包分析. 1,嗅探硬件. 从iOS模拟器捕获数据包不需要做特别的硬件或网络配置.如果需要捕获这些数据包,那么可以使用嗅探软件来监听回送设备或是用于连 ...
- 前端hash路由基本原理,及代码的基本实现
路由就是指随着浏览器地址栏的变化,展示给用户的页面也不相同. 早期的路由都是后端实现的,直接根据 url 来 reload 页面,页面变得越来越复杂服务器端压力变大,随着 ajax 的出现,页面实现非 ...