select USER_CODE,CN_NAME from sys_user where ID in (
select USER_ID from sys_user_org where ORG_ID in (
select ID from (select t1.ID,
if(find_in_set(PARENT_ID, @pids) > 0, @pids := concat(@pids, ',', ID), if(CODE = #{orgCode},ID,0)) as ischild
from (
select ID,CODE,PARENT_ID,NAME from sys_org t ORDER BY ORG_DESC,ID
) t1,
(select @pids := IFNULL((SELECT ID FROM sys_org where CODE = #{orgCode}),'') ) t2
) t3 WHERE ischild != 0)) order by ID
mysql查询机构下的所有子机构
最新推荐文章于 2024-06-26 00:40:40 发布