List:General Discussion« Previous MessageNext Message »
From:Tom Cunningham Date:February 24 2005 5:31pm
Subject:INSERT .. SELECT ... ON DUPLICATE KEY UPDATE
View as plain text  
It appears you can't combine an insert-select with an on-duplicate-key-update.

I would find it very useful if you *could* do this. I know it would be
complicate how you would handle the syntax for what to do when you hit
a duplicate key, could do this: update all the columns that are *not*
involved in duplicate-key clashes.

This would help in situations like the following:

--> You have a table with some columns that are unique, & other
columns which are descriptive of those unique combinations. You also
have an auto-increment key.
--> You have a lot of data you want to insert into this table, & add
new entries where you haven't before heard of that combination of
unique-keys, & otherwise update the non-unique columns.

Possibilities:
1. INSERT IGNORE: doesn't update the non-unique columns.
2. REPLACE: screws up the auto-increment columns.

Any other ideas?

Note: the situation described is one you find when implementing
data-warehouse so-called "slowly changing dimensions".

Tom.
Thread
INSERT .. SELECT ... ON DUPLICATE KEY UPDATETom Cunningham24 Feb
  • Re: INSERT .. SELECT ... ON DUPLICATE KEY UPDATESGreen24 Feb
  • Re: INSERT .. SELECT ... ON DUPLICATE KEY UPDATESergei Golubchik25 Feb
    • Re: INSERT .. SELECT ... ON DUPLICATE KEY UPDATETom Cunningham28 Feb