update dept b, (select group_concat(t.deptId), group_concat(d.deptName separator ‘/‘) as dName, t.id, t.deptName from (select substring_index(substring_index(a.deptId,‘,‘,b.help_topic_id+1),‘,‘,-1) as deptId, a.id, a.deptName
from
(select d.father AS deptId , d.id, d.deptName
from dept d ) a
join mysql.help_topic b on b.help_topic_id < (length(a.deptId) - length(replace(a.deptId,‘,‘,‘‘))+1)) t LEFT JOIN dept d on t.deptId = d.id where t.deptId != ‘‘
GROUP BY id, deptName ) c set b.location=c.dName where b.id = c.id
效果如图
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-10 10:52:23