且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL在重复键上插入行更新多列

更新时间:2023-02-02 22:15:27

INSERT INTO tb (name, date, stat1, stat2, stat3)
VALUES (?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE stat1 = stat1 + VALUES(stat1), stat2 = stat2 + VALUES(stat2), stat3 = stat3 + VALUES(stat3)