Reputation: 3539
How do I update the entire row with this statement
INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;
But I want to update all fields besides the primary key which auto-increments. How?
Upvotes: 2
Views: 4193
Reputation: 43299
Just add them to the second row like this:
INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1, b=b+3, ...
On multiple inserts at once, you can refer to the values like this:
INSERT INTO table (a,b,c) VALUES (1,2,3),(4,5,6)
ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b);
Have look at the Docs for more info on syntax.
Upvotes: 2