首页 > 其他 > 详细

CET递归

时间:2018-09-19 17:01:13      阅读:212      评论:0      收藏:0      [点我收藏+]
WITH cte_name
AS
(
--Anchor member is defined
select PCY_Name,PCY_ID,PCY_Parent,PCY_Code,PCY_Status from PB_Code_MaterType where PCY_ID=2001001001000000
UNION ALL
--Recursive member is defined referencing cte_name
select a.PCY_Name,a.PCY_ID,a.PCY_Parent,
a.PCY_Code,a.PCY_Status from PB_Code_MaterType a
inner join cte_name c on a.PCY_Parent=c.PCY_ID
)
-- Statement using the CTE
SELECT *,(select PCY_Name from PB_Code_MaterType where PCY_ID=cte_name.PCY_Parent)PCY_ParentTxt
FROM cte_name

 

CET递归

原文:https://www.cnblogs.com/lystory/p/9675350.html

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