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. OC语言BLOCK和协议

    OC语言BLOCK和协议 一.BOLCK (一)简介 BLOCK是什么?苹果推荐的类型,效率高,在运行中保存代码.用来封装和保存代码,有点像函数,BLOCK可以在任何时候执行. BOLCK和函数的相似 ...

  2. iOS开发UI篇—iOS开发中三种简单的动画设置

    iOS开发UI篇—iOS开发中三种简单的动画设置 [在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView b ...

  3. StringUtils工具类的常用方法

    StringUtils 方法的操作对象是 java.lang.String 类型的对象,是对 JDK 提供的 String 类型操作方法的补充,并且是 null 安全的(即如果输入参数 String ...

  4. vm10虚拟机安装Mac OS X10.10教程[转]

    update:http://www.sysprobs.com/vmware-workstation-8-0-8-0-1-unlocker-to-run-mac-os-x-guest-in-window ...

  5. appcan.windw.open appcan.frame.open appcan.window.openPopOver evaluateScript

    在模拟器上,几种发方式产生的窗口,其实都是iframe. 在根窗口(app打开的第一个)执行JS: try{ appcan.window.evaluateScript( { name: 'root', ...

  6. CodeForces 360E Levko and Game(Codeforces Round #210 (Div. 1))

    题意:有一些无向边m条权值是给定的k条权值在[l,r]区间可以由你来定,一个点s1 出发一个从s2出发  问s1 出发的能不能先打到f 思路:最短路. 首先检测能不能赢 在更新的时候  如果对于一条边 ...

  7. golang——slice使用摘要

    1.slice因capacity不足而重新分配的underlying array与原本的array空间是断裂的,就是说这是原本指向的空间没变,如下 arr := [...]int{1, 2, 3, 4 ...

  8. Struts1的核心对象

    1.ActionServlet.ActionMapping.ActionForm.ActionForward 2.config = "/WEB-INF/struts-config.xml&q ...

  9. c# windows编程控件学习-1

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  10. UIImageView变灰

    1.UIImageView圆角 CALayer *l = [cell.imgAvatarImage layer]; [l setMasksToBounds:YES]; [l setCornerRadi ...