SQL的判断重复新增或者修改
Posted 大黑的博客园
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL的判断重复新增或者修改相关的知识,希望对你有一定的参考价值。
<insert id="insertTankStatisticData" parameterType="java.util.Map"> <selectKey keyProperty="count" resultType="int" order="BEFORE"> select count(*) AS count from rpt_jiayouzhouqibiao where KehuID=#{KehuID} </selectKey> <if test="count>0"> UPDATE rpt_jiayouzhouqibiao SET KehuName = #{KehuName}, Yewuyuan = #{Yewuyuan}, Chanpin = #{Chanpin}, LastTankDate = #{LastTankDate}, BeforeLastTankDate = #{BeforeLastTankDate}, Shuliang = #{Shuliang}, Pingjunshuliang = #{Pingjunshuliang}, NextTankDate = #{NextTankDate}, TankPeroid = #{TankPeroid}, UpdateTime = getDate() WHERE KehuID = #{KehuID} </if> <if test="count==0"> INSERT INTO rpt_jiayouzhouqibiao( KehuID, KehuName, Yewuyuan, Chanpin, LastTankDate, BeforeLastTankDate, Shuliang, Pingjunshuliang, NextTankDate, TankPeroid, CreateTime ) VALUES ( #{KehuID}, #{KehuName}, #{Yewuyuan}, #{Chanpin}, #{LastTankDate}, #{BeforeLastTankDate}, #{Shuliang}, #{Pingjunshuliang}, #{NextTankDate}, #{TankPeroid}, getDate() ) </if> </insert>
以上是关于SQL的判断重复新增或者修改的主要内容,如果未能解决你的问题,请参考以下文章
SQL SERVER 新增表新增字段修改字段 判断表是否存在
spark关于join后有重复列的问题(org.apache.spark.sql.AnalysisException: Reference '*' is ambiguous)(代码片段