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);
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With