sql使用cte表达式进行递归查询

--递归获取所有子节点
with temp as
(
select * from MK_Base_Department where F_DepartmentId='5f258320-c1b7-42a4-b2fe-cafbd7a190ba'
union all
select a.* from MK_Base_Department a,temp b where a.F_ParentId=b.F_DepartmentId
)
select * from temp

 

posted @ 2019-06-20 14:16  shenjuncaci  阅读(223)  评论(0编辑  收藏  举报