sqlserver 2008 start with connect by 实现

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;

猜你喜欢

转载自lizihong.iteye.com/blog/2245810