sql查询父节点下的子节点的用户(包括父节点的用户)

with myT as(
select id ,parent_id from organization
),
myT2 as(
select * from myT where parent_id in(#{upperId})
union all
select myT.* from myT2 inner join myT 
 on myT2.id=myT.parent_id
)
select u.id from myT2 t
join [user] u on t.id=u.upper_id
union all 
select id from [user] where id=#{userId}

 

posted @ 2019-08-12 14:01  jack_zc  阅读(583)  评论(0编辑  收藏  举报