编写xml形式sql语句注意事项
1.在update中,如果只是按照对方传入的值进行set可以如下:
<update id="updateTable" parameterType="类名"> update table_name <trim prefix="SET" suffixOverrides=","> <if test="字段!= null">DEL_FLAG = #{字段},</if> </trim> where Id= #{id} </update>
2.如果需要将其自行设置成固定值。如下
<update id="updateTable" parameterType="类名">
update table_name
<trim prefix="SET" suffixOverrides=",">
<if test="true">字段= 'x',</if>
</trim>
where Id= #{id}
</update>