in reply to OT: MySQL combine 2 tables data when Perl 'fails'

I think you want UNION ALL. This code works on ORACLE, I'm not sure about MySQL.
INSERT INTO c ( SELECT tok, sum(count) FROM ( SELECT tok, count FROM a UNION ALL SELECT tok, count FROM b ) GROUP BY tok )

--

flounder

Replies are listed 'Best First'.
Re: Re: OT: MySQL combine 2 tables data when Perl 'fails'
by tachyon (Chancellor) on Feb 10, 2004 at 21:35 UTC

    Sadly MySQL is not Oracle and has only basic support for sub-selects. It is pretty annoying at times.

    cheers

    tachyon

      Just use a temporary table
      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;

      --

      flounder