sqlserver 向上递归 向下递归我知道了,但是如何向上递归难
withcteas(selectIdfromt_categorywhereId=20unionallselectc.Idfromt_categorycinnerjoinc...
with cte as (
select Id from t_category where Id = 20
union all
select c.Id from t_category c inner join cte on cte.Id =c.parent
)
select * from cte 展开
select Id from t_category where Id = 20
union all
select c.Id from t_category c inner join cte on cte.Id =c.parent
)
select * from cte 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询