读书人

db2 递归函数小示范

发布时间: 2012-09-10 11:02:32 作者: rapoo

db2 递归函数小示例

with rpl(id,name,parent) as (

select id,name,parent from A_ORGAN where id=999

union all

select t1.id,t1.name,t1.parentfrom rpl t2,A_ORGAN t1 where t2.id=t1.parent

)

selectdistinct id,name,parent from rpl order by id asc

?

select t1.id,t1.name from A_ORGANt1 where ?t1.ID=999 or t1.PARENT=999 order by t1.id asc

读书人网 >其他数据库

热点推荐