SELECT
u.ID,
u.USERNAME,
U.LEVEL,
IFNULL(o.name, u.ORG_ID),
IFNULL(c.name, u.CLASS_ID),
u.NAME
FROM
admin_user u
LEFT JOIN org_info o
ON u.ORG_ID = o.ORG_ID
LEFT JOIN class_info c
ON u.CLASS_ID = C.CLASS_ID ;
SELECT a.id, a.username,a.level,case a.org_id WHEN 0 then 0 else b.name end as org_id, case a.class when 0 then 0 else c.name end as org_id,a.NAME
from admin_user a
left join org_info b on a.org_id = b.org_id
left jon class_info c on a.class_id = c.id
select a.id,a.username,a.level,
case a.ori_id when '1' then '组织1' else '0' end as [org_id],
case a.class_id when '1' then '班级1' else '0' end as [class_id],
a.name from admin_user a,class_info b,org_info c
where a.id=b.id and a.org_id = c.org_id