首页 > 数据库技术 > 详细

SQL2005的cte递归查询子树

时间:2015-10-21 15:34:32      阅读:213      评论:0      收藏:0      [点我收藏+]

;with cte
as(
select id,caption,parentid,1 Gen from skywfflow where parentid =0
UNION ALL
select a.id,a.caption,a.parentid,cte.gen+1 Gen from skywfflow a
 inner join cte on a.parentid=cte.id
)
select * from cte

SQL2005的cte递归查询子树

原文:http://www.cnblogs.com/hz-blog/p/4897763.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!