sql server递归

with cte as
(
select belongsAgent from [QPProxyDB].[dbo].[BS_ProxyInfo] where ProxyID = @ProxyID 
union all
select a.ProxyID from [QPProxyDB].[dbo].[BS_ProxyInfo] a join cte b on a.ProxyID = b.belongsAgent
)
select * from cte order by belongsAgent asc

 

ProxyID 父级

belongsAgent 子集

本文由必威发布于必威-数据,转载请注明出处:sql server递归

TAG标签:
Ctrl+D 将本页面保存为书签,全面了解最新资讯,方便快捷。