List:General Discussion« Previous MessageNext Message »
From:Phil Date:July 21 2008 5:16pm
Subject:Re: "Insert ... select ... On Duplicate Update" Question
View as plain text  
So just use REPLACE instead of INSERT...

http://dev.mysql.com/doc/refman/5.0/en/replace.html

On Mon, Jul 21, 2008 at 11:44 AM, mos <mos99@stripped> wrote:

> At 08:23 PM 7/20/2008, Perrin Harkins wrote:
>
>> On Sun, Jul 20, 2008 at 12:12 AM, mos <mos99@stripped> wrote:
>> > Is there a way to get "Insert ... select  ... On Duplicate Update" to
>> update
>> > the row with the duplicate key?
>>
>> That's what it does.
>>
>> > Why can't it do this?
>>
>> What makes you think it can't?
>>
>> - Perrin
>>
>
> Perrin,
>       I can't specify all of the columns in a Set statement in the
> OnDuplicate clause because I don't know what the column names are and there
> could be 100 columns. I'd like to use something like:
>
> insert into Table2 select * from table1 on duplicate key update;
>
> but this gives me a syntax error.
>
> Error Code : 1064
> You have an error in your SQL syntax; check the manual that corresponds to
> your MySQL server version for the right syntax to use near '' at line 1
>
> So it is looking for an Update expression. I'd like it to update all the
> columns in the Select statement to the row with the matching key. After all,
> this is what the statement was trying to do in the first place. I don't see
> why I have to explicitly specify all of the value assignments in the On
> Duplicate phrase over again.
>
> Mike
> MySQL 5.0.24
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
>


-- 
Help build our city at http://free-dc.myminicity.com !

Thread
"Insert ... select ... On Duplicate Update" Questionmos20 Jul
  • Re: "Insert ... select ... On Duplicate Update" QuestionPerrin Harkins21 Jul
    • Re: "Insert ... select ... On Duplicate Update" Questionmos21 Jul
      • Re: "Insert ... select ... On Duplicate Update" QuestionPerrin Harkins21 Jul
        • Re: "Insert ... select ... On Duplicate Update" Questionmos21 Jul
      • Re: "Insert ... select ... On Duplicate Update" QuestionPhil21 Jul
Re: "Insert ... select ... On Duplicate Update" Questionmos21 Jul
  • Re: "Insert ... select ... On Duplicate Update" QuestionPerrin Harkins21 Jul