select * from(selct a1,b1 from table1 where 条件 union select a1,b1 from table2 where 条件 ) as table3 group by a1;