当前位置:数据库 > Oracle >>

oracle树查询语句

oracle树查询语句
 
oracle 
select   *   from  tab_organization  start  with   strupcode is null  connect   by   prior   strcode=strupcode  order siblings   by   strcode   asc 

.....start  with  .A... connect   by  prior ...B  ..order  siblings   .C 

 

 
注意:tab_organization 中的strupcode是父节点的编码,这是一个关联。 
 
A:表示顶级节点的条件,这里是  strupcode is null 
 
B:上下两级节点关联的条件,strcode=strupcode,当前节点的strcode等于下级节点的strupcode. 
 
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,