标签:写法 count cat customer 简单的 记录 insert led duplicate
首先主键是索引
insert into ys_yssf_rj
(customerId,settleDate,settleMoney,
settleActual, settleBalance,settleAccountState)
VALUES
(#customerId#,now(),#settleMoney#,
#settleActual#,#settleBalance#,#settleAccountState#
)
ON DUPLICATE KEY UPDATE
settleDate = now(),
settleMoney = #settleMoney#,
settleActual = #settleActual#,
settleBalance = #settleBalance#,
settleAccountState = #settleAccountState#
以前的做法是先根据主键去查找是否存在记录,找到就update,找不到就insert。需要写两条语句
on duplicate key update 的写法,很简单的解决了上面的问题,而且只需要写一条语句。
标签:写法 count cat customer 简单的 记录 insert led duplicate
原文地址:https://www.cnblogs.com/lqh969696/p/11387451.html