gpt4 book ai didi

mysql - 设置旧值 = 旧值 + 新值 ON DUPLICATE KEY

转载 作者:行者123 更新时间:2023-11-29 16:06:50 29 4
gpt4 key购买 nike

我看到这个例子,我想用旧值+新值更新旧值

INSERT INTO mytable (id, a, b, c)
VALUES (1, 'a1', 'b1', 'c1'),
(2, 'a2', 'b2', 'c2'),
(3, 'a3', 'b3', 'c3'),
(4, 'a4', 'b4', 'c4'),
(5, 'a5', 'b5', 'c5'),
(6, 'a6', 'b6', 'c6')
ON DUPLICATE KEY UPDATE id=VALUES(id),
a=VALUES(old a+ new a),
b=VALUES(old b+ new b),
c=VALUES(old c+ new c);

最佳答案

谢谢,我已经解决了我的问题

INSERT INTO mytable (id, a, b, c)
VALUES (1, 'a1', 'b1', 'c1'),
(2, '5', '6', '7'),
(3, '5', '6', '7'),
(4, '5', '6', '7'),
(5, '5', '6', '7'),
(6, '5', '6', '7')
ON DUPLICATE KEY UPDATE id=VALUES(id),
a=a+VALUES(a),
b=b+VALUES(b),
c=c+VALUES(c);

关于mysql - 设置旧值 = 旧值 + 新值 ON DUPLICATE KEY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55665496/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com