mybatis常用的标签

CHOOSE-WHEN标签:
<choose>
    <when test="expiredFlag==0">
        AND
        b.EX_STATUS not in('EXPIRED','PREEXPIRED')
    </when>
    <otherwise>
        AND
        b.EX_STATUS in('EXPIRED','PREEXPIRED')
    </otherwise>
</choose>

这里面test如果要做判断多个条件,最外层用单引号

<when test='item.estCount !=null and item.estCount =="4"'>
    and A.est4_date = #{item.estOneDate},
</when>

if标签:

<if test="sizing != null and sizing != ''">
    AND
    a.EXP_CON_TYPE = #{sizing}
</if>
where标签:
<where>
    <if test="mainMatCode != null and mainMatCode != ''">
        and MAIN_MAT_CODE = #{mainMatCode}
    </if>
    <if test="accessoryMatCode != null and accessoryMatCode != ''">
        and ACCESSORY_MAT_CODE = #{accessoryMatCode}
    </if>
</where>

set标签:

<set>
    <if test="ordNo != null and ordNo != ''">
        ORD_NO = #{ordNo},
    </if>
    <if test="itemNo != null and itemNo != ''">
        ITEM_NO = #{itemNo},
    </if>
</set>

trim标签:

<trim prefix="WHERE" prefixoverride="AND |OR">

    <if test="name != null and name.length()>0"> AND name=#{name}</if>

    <if test="gender != null and gender.length()>0"> AND gender=#{gender}</if>

</trim>

update user

<trim prefix="set" suffixoverride="," suffix=" where id = #{id} ">

    <if test="name != null and name.length()>0"> name=#{name} , </if>

    <if test="gender != null and gender.length()>0"> gender=#{gender} ,  </if>

</trim>

bind标签

<if test="name != null and name !=''">      <bind name="nameLike" value="'%'+name+'%'"/>      and name like #{nameLike} </if>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值