tags:

views:

365

answers:

1

How can I use the ON DUPLICATE UPDATE with a multiple value INSERT?

INSERT INTO tbl_name 
  (key_id,field1,filed2) 
VALUES
  (1,2,3),
  (1,5,6),
  (1,8,9);
+4  A: 

I can not try it right now, but can't you use this syntax

INSERT INTO table (a,b,c) VALUES (1,2,3),(4,5,6)
  ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b);

from the manual?

Guess your syntax would then look like this:

INSERT INTO tbl_name
  (key_id,field1,filed2) 
VALUES
  (1,2,3),
  (1,5,6),
  (1,8,9)
ON DUPLICATE KEY
  UPDATE field1=VALUES(field1), field2=VALUES(field2);
Peter Lang
I must have missed this, thnx
Phill Pafford