天天看點

springboot mybatis merge into 用法

例子:

<update id="insert" parameterType="***.***.***.實體">
   merge into 表名 a
     using (select 1 from dual)
       on (a.字段1 = #{參數} and a.字段2 = #{參數2})
       when not matched then
         insert (字段1,字段2,字段3)
     	   values(#{參數1,jdbcType=VARCHAR},#{參數2,jdbcType=VARCHAR},#{參數3,jdbcType=VARCHAR})
       when matched then
         update set counts = counts + 1, last_time = sysdate, 字段1 = #{參數1,jdbcType=VARCHAR}
</update>
           

繼續閱讀