导出二级单位下的所有管理岗位,部门要分级

时间:2023/8/12 17:44:47 赞:0 踩:0 阅:312 标签:分级拼接

select GetDeptSon(261);   --长北

SELECT post_name,CONCAT_WS('/', d3.`dept_name`, d2.`dept_name`, d1.`dept_name`) AS department FROM POSITION u
join dept d1 on u.dept_id=d1.dept_id
left join dept d2 on d1.parent_id=d2.dept_id
left join dept d3 on d2.parent_id=d3.dept_id
left join dept d4 on d3.parent_id=d4.dept_id
WHERE u.POST_TYPE=2 AND find_in_set(u.DEPT_ID,'261,345,347,348,349,350,2408,2514,2515,10041,2516,9721,9822,9967,10050,10053,9240,9242,9525,9531,9584,9596,9597,9598,9605,9607,9614,9615,9636,9658,9659,9660,9661,9728,9734,9735,9736,9737,9738,9739,9740,9741,9742,9743,9755,9756,9757,9758,9770,9777,9778,9779,9780,9781,9782,9969,9970,9972,9973,9974,9823,9824,9825,9826,9720,9977,10051,10052,10159');

select GetDeptSon(2429); --苏南

SELECT post_name,CONCAT_WS('/', d4.`dept_name`,d3.`dept_name`, d2.`dept_name`, d1.`dept_name`) AS department FROM POSITION u
join dept d1 on u.dept_id=d1.dept_id
left join dept d2 on d1.parent_id=d2.dept_id
left join dept d3 on d2.parent_id=d3.dept_id
left join dept d4 on d3.parent_id=d4.dept_id
WHERE u.POST_TYPE=2 AND find_in_set(u.DEPT_ID,'2429,4879,8359,8417,8418,8419,8420,8421,8422,8523,8524,8525,4884,8423,8424,8425,8967,10278,8968,8969,8970,8971,8972,10279,10280');

 

结果如下:

评论一下

发表评论

注册用户登录后才能发表评论,请登录注册