start with
来源:互联网 发布:写字板软件下载 编辑:程序博客网 时间:2024/04/28 16:01
--根据部门编码查询其对应的大区或大区的平级
select *
from t_org_department d
where d.deptlevel = 4
start with d.finasyscode = 'DP02035'
connect by prior d.parentid = d.id
connect by 是结构化查询中用到的,其基本语法是:
select … from tablename
select … from tablename
start with 条件1
connect by 条件2
where 条件3;
例:
select * from table
start with org_id = ‘HBHqfWGWPy’
connect by prior org_id = parent_id;
connect by 条件2
where 条件3;
例:
select * from table
start with org_id = ‘HBHqfWGWPy’
connect by prior org_id = parent_id;
简单说来是将一个树状结构存储在一张表里,比如一个表中存在两个字段:
org_id,parent_id那么通过表示每一条记录的parent是谁,就可以形成一个树状结构。
用上述语法的查询可以取得这棵树的所有记录。
其中:
条件1 是根结点的限定语句,当然可以放宽限定条件,以取得多个根结点,实际就是多棵树。
条件2 是连接条件,其中用PRIOR表示上一条记录,比如 CONNECT BY PRIOR org_id = parent_id;就是说上一条记录的org_id 是本条记录的parent_id,即本记录的父亲是上一条记录。
条件3 是过滤条件,用于对返回的所有记录进行过滤。
其中:
条件1 是根结点的限定语句,当然可以放宽限定条件,以取得多个根结点,实际就是多棵树。
条件2 是连接条件,其中用PRIOR表示上一条记录,比如 CONNECT BY PRIOR org_id = parent_id;就是说上一条记录的org_id 是本条记录的parent_id,即本记录的父亲是上一条记录。
条件3 是过滤条件,用于对返回的所有记录进行过滤。
0 0
- start with
- start with
- start with
- START WITH
- Start with Ajax.NET
- Getting start with SOA
- start with Debian
- Start coding with XAML
- Getting Start with GlovePIE
- start with 、replace
- 2.Start with
- Start with WinMain
- getting start with osip
- Start Game with OGRE
- Getting start with AWK
- Start with spring mvc
- Get Start With NuGet
- insert、start with
- mysql忘记root密码的解决办法
- IEnumerable
- SPOJ MYQ10 (数位DP)
- 用 Windows Live Writer 写博客配置备忘
- Linux下crontab的使用
- start with
- Annotation
- the c programing language 练习1-17
- C++0X的三件好东西(零)
- 数据泵
- Java笔记七.线程间通信与线程生命的控制
- 快速掌握一个语言最常用的50%
- Nmap 空闲扫描
- oracle基本语法