sqlserver 递归

 


with cte_parent
as
(
select t1.name,t1.parentCode from UserOrgZt as t1
left join UserZt as t2 on t1.guid = t2.orgGuid
where t2.email ='xxxx@cohl.com'
union all
select a.name,a.parentCode from UserOrgZt a
inner join cte_parent b
on a.guid= b.parentCode
),
tab as(
select name, '1' as type from cte_parent
)
select
stuff((select ','+name from tab
where c.type=type
for xml path('')),1,1,'') as name
from tab c
group by c.type

 

 

 

参考此链接

https://blog.csdn.net/smartsmile2012/article/details/80950919?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

posted @ 2020-03-27 13:35  林鹿鸣  阅读(200)  评论(0编辑  收藏  举报
canvas#live2dcanvas { border: 0 !important; right: 0; //修改动画在左右的位置 }