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>
posted @ 2024-01-17 15:04  Cold的窝  阅读(5)  评论(0)    收藏  举报