https://blog.csdn.net/t8116189520/article/details/78908975
所以,若想基于插入值累加是不行的,需要insert into
https://www.cnblogs.com/lixiaozhi/p/8193132.html
INSERT INTO TABLE (a,b,c) VALUES
(1,2,3),
(2,5,7),
(3,3,6),
(4,8,2)
ON DUPLICATE KEY UPDATE b=VALUES(b) + b;
这样子;
mybatis中写法:
<update id="merge">
insert into
namelist_statistics_modify
(
id ,
oc_date ,
statis_type ,
type_value ,
list_type ,
fraud_type ,
field_type ,
total_count ,
good_count ,
modify_no ,
create_by
)
values
<foreach collection="modifyInfoList" item="modifyInfo" index="index" separator=",">
(
#{modifyInfo.id} ,
#{modifyInfo.ocDate} ,
#{modifyInfo.statisType} ,
#{modifyInfo.typeValue} ,
#{modifyInfo.listType} ,
#{modifyInfo.fraudType} ,
#{modifyInfo.fieldType} ,
#{modifyInfo.totalCount} ,
#{modifyInfo.goodCount} ,
#{modifyInfo.modifyNo} ,
#{modifyInfo.createBy}
)
</foreach>
on duplicate key
update
total_count = total_count + values(total_count) ,
good_count = good_count + values(good_count)
</update>