mybatis 增删改模板
insert into 表名
<trim prefix="(" suffixOverrides="," suffix=")">
<if test="字段名 != null">
字段名,
</if>
</trim>
<trim prefix="values(" suffixOverrides="," suffix=")">
<if test="字段名 != null">
#{字段名},
</if>
</trim>
delete from 表名
<where>
<if test="字段名 != null">
字段名 = #{字段名}
</if>
</where>
update 表名
<set>
<if test="字段名 != null">
字段名 = #{字段名},
</if>
</set>
<where>
<if test="字段名 != 字段名">
字段名 = #{字段名}
</if>
</where>
select * from 表名
<where>
<if test="字段名 != null">
字段名 = #{字段名}
</if>
</where>

浙公网安备 33010602011771号