db2递归查询

查询机构14159下的所有子孙节点

WITH n(orgid,orgupid,orgname) AS(
SELECT SYS_ORG_ID,SYS_ORG_UPID,SYS_ORG_NAME FROM SYS_ORG_TB WHERE SYS_ORG_ID=14159
UNION ALL
SELECT t2.SYS_ORG_ID,t2.SYS_ORG_UPID,t2.SYS_ORG_NAME  FROM n t1,SYS_ORG_TB t2 WHERE t1.orgid=t2.SYS_ORG_UPID
)
SELECT * FROM n

 

posted @ 2018-04-26 14:30  _revolution  阅读(223)  评论(0编辑  收藏  举报