------解决方案-------------------- select case when a.dptid=0 then b.depname='' end,a,code,a.name b.depname from a,b where a.deptid=b.id
------解决方案--------------------
select IF(a.dptid=0,'',b.depname),a,code,a.name b.depname from a INNER JOIN b ON a.deptid=b.id
------解决方案--------------------