select * from table1
union
select * from table2

解决方案 »

  1.   

    你这样会显示两个name为x的数据,并不汇总,我的意思是,name不同的直接显示,如相同则汇总。
      

  2.   

    select name,sum(a) as a,sum(b) as b,sum(c) as c,sum(d) as d,sum(e) as e from 
    (select name, a, b, c, d, e from table1
    union all
    select name, a1, b1 c1 d1 e1 from table2
    ) aa
    group by name
      

  3.   

    select name,sum(a),sum(b),sum(c),sum(d),sum(e)
    from(
    select * from table1
    union all
    select * from table2)
    group by name