你的group by语句呢,不会是在最后面直接加的group by吧
select * from (select * from a union all select * from b) c group by c.id