Oracle中的select语句可以用start with...connect by prior子句实现递归查询,connect by 是结构化查询中用到的,

其基本语法是:

select ... from <TableName>
where <Conditional-1>
start with <Conditional-2>
connect by <Conditional-3>;

<Conditional-1>:过滤条件,用于对返回的所有记录进行过滤;
<Conditional-2>:查询结果重起始根结点的限定条件;
<Conditional-3>:连接条件;

select dept_id ,dept_name,parent_id,stutas ,remark,
level as lev
from pub_depart_info
where stutas=1
start with pub_depart_info.dept_id=''
connect by prior pub_depart_info.dept_id = pub_depart_info.parent_id
order by pub_depart_info.dept_id

其中:level为关键字,用于显示递归的层书

oracle start with connect by prior 递归查询的更多相关文章

  1. oracle start with connect by prior 递归查询用法

    start with 子句:遍历起始条件,有个小技巧,如果要查父结点,这里可以用子结点的列,反之亦然. connect by 子句:连接条件.关键词prior,prior跟父节点列parentid放在 ...

  2. Oracle start with connect by prior 用法

    Oracle start with connect by prior 用法    语法: select * from 表名 where 条件1 start with 条件2 connect by pr ...

  3. Oracle start with.connect by prior子句实现递归查询

    Oracle中的select语句可以用start with...connect by prior子句实现递归查询,connect by 是结构化查询中用到的,其基本语法是: select ... fr ...

  4. 在oracle中通过connect by prior来实现递归查询!

    注明:该文章为引用别人的文章,链接为:http://blog.csdn.net/apicescn/article/details/1510922 ,本人记录下来只是为了方便查看 原文: connect ...

  5. oracle中 connect by prior 递归查询

    Oracle中start with...connect by prior子句用法 connect by 是结构化查询中用到的,其基本语法是: select ... from tablename sta ...

  6. 在oracle中采用connect by prior来实现递归查询

    注明:该文章为引用别人的文章,链接为:http://blog.csdn.net/apicescn/article/details/1510922 , 记录下来只是为了方便查看 原文: connect ...

  7. Start with connect by prior 递归查询

    在SELECT命令中使用CONNECT BY和START WITH子句可以查询表中的树型结构关系.其命令格式如下: SELECT * from CONNECT BY {PRIOR列名1=列名2|列名1 ...

  8. 在Oracle 中使用CONNECT BY PRIOR START WITH 语句详解

    语法:connect by 是结构化查询中用到的,其基本语法如下: start with,connect by主要目的:从表中取出树状数据.可以假想成表中存成的各条数据是分别是树中的一个结点. sel ...

  9. Oracle树查询,start with connect by prior 递归查询用法(转载)

    本人觉得这个写的真不错,实用性强,就转载过来了 这个子句主要是用于B树结构类型的数据递归查询,给出B树结构类型中的任意一个结点,遍历其最终父结点或者子结点. 先看原始数据: 1 create tabl ...

随机推荐

  1. MySQL与SqlServer中update操作同一个表问题

    一 SqlServer中操作如下图 这个是没问题的. 二 MySQL中操作如下图 但是在MySQL中想实现这个功能如下图,但是出错了. 原来是MySQL中不支持子查询的 我们可以这样修改一下就可以实现 ...

  2. plist

    <a title="iphone" href="itms-services://?action=download-manifest&url=https:// ...

  3. Xib与View关联方法

    1,在需要实例的地方 //加载一个uiview的作法 [LotteryInvestigationView *lotteryInvestigationView=[[[NSBundle mainBundl ...

  4. Rhel6-sersync配置文档

    系统环境: rhel6 x86_64 iptables and selinux disabled 主服务器: 192.168.122.160 server60.example.com 目标服务器: 1 ...

  5. ESXi虚拟磁盘共享

    因为项目需要需要一个磁盘共享的环境. 最先想到用iSCSI,两个客户端挂载同一个远端盘:这样确实可行,但是感觉太繁琐,想到既然是虚拟机环境,可以设置虚拟磁盘共享. 于是网上一番搜罗,确实有人这个做过, ...

  6. Python的平凡之路(6)

    一.面向对象编程介绍 1 编程范式:          编程范式(Programming Paradigm)是某种编程语言典型的编程风格或者说是编程方式.随着编程方法学和软件工程研究的深入,特别是OO ...

  7. C#中的IntPtr类型

    本文转自:http://zhidao.baidu.com/question/22825956.html 问: c#中无法将类型“int”隐式转换为“System.IntPtr” 这个是我引用了一个ap ...

  8. My first Scratch small game

    My first Scratch small game:https://scratch.mit.edu/projects/62700370/ PC or Mac only. Browser & ...

  9. Unity Sprite切割导出

    这次需要将美术提供的Sprite图集切割导出,整体思路依然和上次的Sprite转prefab一致,只是在转prefab的逻辑修改为了创建Texture的逻辑. 过程很简单,直接看最终代码结果: usi ...

  10. cocos2dx常见的46中+22中动作详解

    cocos2dx常见的46中+22中动作详解 分类: iOS2013-10-16 00:44 1429人阅读 评论(0) 收藏 举报 bool HelloWorld::init(){    ///// ...