create table d SELECT tok, count FROM a UNION ALL SELECT tok, count FROM b; insert into c select tok, sum(count) as count from d group by tok; drop table d;