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

Oracle层级语句-树形结构-显示根节点-不显示根节点

Oracle层级语句-树形结构-显示根节点-不显示根节点
 
.Oracle 层级语句 树形结构
area_id 就是普通的主键ID  与 parent_id 对应..行政区划表
1.  start with t.parent_id 这里为parent_id 不显示顶端根结点,这样会有多个根
[sql] 
select t.* from HM_F_AREA t where length(t.area_id) = 6  
  start with t.parent_id = '510000'  
  connect by t.parent_id = PRIOR t.area_id  

 

 
 
2.start with t.id 如果为ID 就是显示根,只有一个根
[sql] 
select t.* from HM_F_AREA t where length(t.area_id) = 6  
  start with t.area_id = '510000'  
  connect by t.parent_id = PRIOR t.area_id  

 

.
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,