select a.id,a.name,(case a.groupid when 1 then b.groupname else '其它组' when 2 then b.groupname else '其它组' when 3 then b.groupname else '其它组' end) as groupid from 人员 a inner join 小组 b on a.groupid=b.groupid
select b.id,name,组名=case when a.id=1 then GroupName when a.id=2 then GroupName when a.id=3 then GroupName else '其它组' end from a right join b on a.id=b.groupid