这有何难:
select t3.*,case when(t3.gid=0) then (select t1.email from t1 where t1.uid=t3.uid) else (select t2.email from t2 where t2.gid=t3.gid) end from t3
select b.email,
a.name
from tb3 a, tb1 b
where a.gid = 0
and a.uid = b.uid
union all
select b.email,
a.name
from tb3 a, tb2 b
where a.uid = 0
and a.gid = b.gid;