<insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.xxx.xxx.UserDO" useGeneratedKeys="true">
INSERT INTO user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
name,
</if>
<if test="accountId != null">
account_id,
</if>
<if test="gmtCreate != null">
gmt_create,
</if>
<if test="gmtModified != null">
gmt_modified,
</if>
<if test="isDelete != null">
is_delete,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</if>
<if test="name != null">
#{name},
</if>
<if test="accountId != null">
#{accountId},
</if>
<if test="gmtCreate != null">
#{gmtCreate},
</if>
<if test="gmtModified != null">
#{gmtModified},
</if>
<if test="isDelete != null">
#{isDelete},
</if>
</trim>
ON duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id =#{id},
</if>
<if test="name != null">
name =#{name},
</if>
<if test="accountId != null">
account_id = #{accountId},
</if>
<if test="gmtCreate != null">
gmt_create = #{gmtCreate},
</if>
<if test="gmtModified != null">
gmt_modified = #{gmtModified},
</if>
<if test="isDelete != null">
is_delete = #{isDelete},
</if>
</trim>
</insert>
标签:insert,name,gmtCreate,update,mysql,id,gmt From: https://www.cnblogs.com/gylhaut/p/17124908.html