欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

sqlserver 2008 start with connect by 实现  

程序员文章站 2022-03-25 22:58:59
...
with subqry(id,name,parent_id) as(
  select id,name,parent_id from pro_type_manage where id in ('5799936','5799946')  -- start with
  union all
  select test1.id,test1.name,test1.parent_id from pro_type_manage as test1,subqry
  where test1.parent_id = subqry.id --connect by
  )
  select* from subqry;