mysql replaceinto VS insertinto

https://blog.csdn.net/t8116189520/article/details/78908975

Therefore, if you want based on the accumulated value is not inserted, it is necessary 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;

in this way;

mybatis in writing:

<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>

 

Guess you like

Origin www.cnblogs.com/do-your-best/p/11375474.html