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

 

你可能感兴趣的:(sql使用cte表达式进行递归查询)