Thank you for your fast reply!
On Wed, Oct 7, 2009 at 6:25 PM, ewen fortune <ewen.fortune@stripped> wrote:
> Why not use INSERT ON DUPLICATE KEY UPDATE.
>> So, If I want to insert-update the record "(a1,b2),b3" the two cases would be:
>> a) record "(a1,a2),a3" exists and has a matching "a1"
>> --update-to--> "(a1,b2),b3"
>> b) there doesn't exist any record matching a1
>> ----insert---> "(a1,b2),a3"
> INSERT INTO table (a,b,c) VALUES (1,2,3)
> ON DUPLICATE KEY UPDATE b=2,c=3;
That has the same effect as REPLACE for me.
The primary key is "a,b" so, it's possible that there's a (1,4,5)
record already in the table that I want updated but INSERT ON
DUPLICATE KEY UPDATE will instead insert a (1,2,3) record (the "a"
field is the same but it still has a different "b" and thus it's a
different primary key, so it's not considered a duplicate).