with dept(deptID,pDeptID)
as
(select uDepID,uParentID from OA.dbo.DepInfo where uDepID in(
select p.uDepID from OA.dbo.PostInfo as p
inner join OA.dbo.UserInPost as up on p.uPostID=up.uPostID
where up.uUserID=@UserID)
union all
select uDepID,uParentID from OA.dbo.DepInfo as di
inner join dept as d on di.uDepID=d.pDeptID
where di.uParentID is not null
)
使用with进行回溯
最新推荐文章于 2023-12-10 20:16:14 发布