一个查询树状结构的语句
SELECT 1,LEVEL,LNAME,NULL,CODE
FROM PRDGP CONNECT BY PRIOR CODE = P_CODE
START WITH P_CODE IS NULL
说明:P_CODE为父级,CODE为子集,P_CODE为空时为树的最顶级,即为Start with 起点,递归方式为CODE = P_CODE,LEVEL为树的等级
SELECT CODE,LNAME,CNAME
FROM PRDGP WHERE CODE <> 'LBL' AND TYPE= 'GMT' CONNECT BY PRIOR CODE=PARENTGRP AND PARENTGRP <> 'LBL'
START WITH PARENTGRP IS NULL ORDER BY CODE
posted on 2008-12-10 15:56
谭明 阅读(381)
评论(0) 编辑 收藏 所属分类:
Oracle