SQL递归查询(with cte as)--postgresql,mysql
with cte as
(
select Id,Pid,DeptName,0 as lvl from Department
where Id = 2
union all
select d.Id,d.Pid,d.DeptName,lvl+1 from cte c inner join Department d
on c.Id = d.Pid
)
select ...
原创
2019-03-15 13:57:44 ·
397 阅读 ·
0 评论