SQL根据某一父节点查询所有子节点,无限

;with cte as
(
select id,ParentCategoryId from Category where id = 17
union all
select a.id,a.ParentCategoryId
from Category a join cte b on a.ParentCategoryId = b.id
where a.id is not null
)

select * from cte

posted @   evemen  阅读(821)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示