sql 树 递归

sql 树 递归

with SubQuery(No,Name,ParentNo) as (  
  select No,[Name],ParentNo from [Port_Dept] where No = '3' 
  union all  
  select A.No,A.Name,A.ParentNo   
  from [Port_Dept] A inner join SubQuery B  
    on A.No = B.ParentNo  
)  
select * from SubQuery  

 

posted @ 2014-04-23 21:20  shiningrise  阅读(213)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css