create table t (id int primary key, sum int);
insert into t set id=1, sum=1 ON DUPLICATE KEY UPDATE sum = sum + 1;
insert into t set id=1, sum=2 ON DUPLICATE KEY UPDATE sum = sum + 2;
insert into t set id=1, sum=3 ON DUPLICATE KEY UPDATE sum = sum + 3;
INSERT INTO t(id, sum) values(1, 1), (1, 2), (1, 3) ON DUPLICATE KEY UPDATE sum=sum+VALUES(sum);
Title:
insert multiple records and update field if duplicate
Description:
create table t (id int primary key, sum int); insert into t set id=1, sum=1 ON DUPLICATE KEY UPDATE sum = sum + 1; insert into t set id=1, s...
...
Rating:
4