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 <[EMAIL PROTECTED]> wrote:

> At 08:23 PM 7/20/2008, Perrin Harkins wrote:
>
>> On Sun, Jul 20, 2008 at 12:12 AM, mos <[EMAIL PROTECTED]> 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/[EMAIL PROTECTED]
>
>


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

Reply via email to