Re: Insert into...on duplicate key problem

2008-07-12 Thread Rob Wultsch
On Wed, Jul 9, 2008 at 9:37 AM, Phil <[EMAIL PROTECTED]> wrote: > Is it possible to do an insert into with subselect and group by with an > additional on duplicate insert ? > > CREATE TABLE NEW_TABLE ( > `a` varchar(10), > `b` double > ) engine=MyISAM; > > > INSERT INTO NEW_TABLE (select old.x,su

Re: Insert into...on duplicate key problem

2008-07-09 Thread Phil
Sorry, that was just a typo, should have been INSERT INTO NEW_TABLE (select old.x,sum(old.y) from OLD_TABLE old group by old.x) on duplicate key update b=sum(old.y); but this gives ERROR (HY000): Invalid use of group function INSERT INTO NEW_TABLE (select old.x,sum(old.y) from OLD_TAB

Re: Insert into...on duplicate key problem

2008-07-09 Thread Ananda Kumar
you should say "group by old.x" and not "old.a" On 7/9/08, Arthur Fuller <[EMAIL PROTECTED]> wrote: > > I think that you need to select old.a otherwise you cannot group by it. > > Arthur > > On 7/9/08, Phil <[EMAIL PROTECTED]> wrote: > > > > Is it possible to do an insert into with subselect and g

Re: Insert into...on duplicate key problem

2008-07-09 Thread Arthur Fuller
I think that you need to select old.a otherwise you cannot group by it. Arthur On 7/9/08, Phil <[EMAIL PROTECTED]> wrote: > > Is it possible to do an insert into with subselect and group by with an > additional on duplicate insert ? > > CREATE TABLE NEW_TABLE ( > `a` varchar(10), > `b` double

Insert into...on duplicate key problem

2008-07-09 Thread Phil
Is it possible to do an insert into with subselect and group by with an additional on duplicate insert ? CREATE TABLE NEW_TABLE ( `a` varchar(10), `b` double ) engine=MyISAM; INSERT INTO NEW_TABLE (select old.x,sum(old.y) from OLD_TABLE old group by old.a) on duplicate key update b=sum(old.y