with Dept as(
select id,departmentname,supdepid from hrmdepartment where id='19'
union all
select HrmDept.id,HrmDept.departmentname,HrmDept.supdepid from hrmdepartment HrmDept,Dept
-- 当前部门所有下级
where HrmDept.supdepid=Dept.id
-- 当前部门所有上级 where T.supdepid=D.id
)
select * from Dept