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的目前版本中还没有对应的功能. ...
随机推荐
- 【JVM】3、JVM问题查找
1.查看tomcat进程号 两种方式都可以查看tomcat进程号 ps -ef | grep tomcat-web jps -lmvV |grep tomcat-web 结果如下:2556 2.查看进 ...
- static ,final 、abstract的作用,以及它们的联系和区别
static可以修饰变量,修饰的变量直接属于某各类,不局限于某个方法,无法在成员方法中修饰变量,也不可以在静态方法中修饰变量.被static修饰的方法属于静态方法(类方法),与对象无关,与类有关.fi ...
- Points on Cycle (hdu1700,几何)
Points on Cycle Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Map集合框架的练习
Map是一个很重要的集合框架,它以键值对的方式存储,下面是一个Map集合的小练习,使用了keySet的取出方法. 取出字符串的每一个字符,记录每一个字母出现的次数.使用Map集合框架. package ...
- Http升级到Https (本地测试,无须域名和认证)
在之前的语音识别的项目中,一切都在本地进行得很顺利,然后把写的Demo部署到服务器上给老大看的时候,通过IP访问(http://192.168.145.170:8080这样的形式)时,从一开始就坏掉了 ...
- Oracle中UNION和ORDER BY共用方法
问题 SQL语句中,UNION拼接两个单独的SQL时候,单独的SQL中加入ORDER BY会报错,ORDER BY只能放在句末. // 会报错的语句 SELECT S.S_ID AS ID,S.S_N ...
- Ajax 滚动异步加载数据
第一种情况:单个div滚动 HTML <body> <!-- search start --> <div class="search" #if($m_ ...
- ionic1 项目微信支付
使用的插件参照地址:https://github.com/xu-li/cordova-plugin-wechat:(这里包含微信登录,微信分享和微信支付) 插件安装 cordova plugin ad ...
- 纯小白入手 vue3.0 CLI - 2.4 - 新组件 Forms.vue 中学习表单
vue3.0 CLI 真小白一步一步入手全教程系列:https://www.cnblogs.com/ndos/category/1295752.html 我的 github 地址 - vue3.0St ...
- Android--监听View的两个指头是放大和缩小
private double nLenStart = 0;//监听 WebView所用手势 @Override public boolean onTouch(View v, MotionEvent e ...