MyBatis中的参数失效情况

MyBatis中的参数失效情况

在写代码的过程中,需要在xml文件中写sql语句进行数据查询,但是测试的过程中发现deleteStatus和type参数为0的时候,相应的sql语句并没有成功拼接

select a.id, a.type, a.style_name, a.item_code, a.title, a.sale, a.technology, a.year,
        a.delete_status, a.publish_status, a.new_status, a.recommend_status, a.hot_status,
        a.keywords,a.img_url, b.price
        from pm_item a
        inner join(SELECT item_id,min(price) price FROM `pm_product` GROUP BY item_id) b on a.id = b.item_id
        where 1=1
        <if test="deleteStatus != null and deleteStatus !=''">
            and a.delete_status=#{deleteStatus}
        </if>
        <if test="type != null and type !=''">
            and a.type = #{type}
        </if>
        <if test="lowPrice != null and lowPrice !=''">
            and b.price &gt;= #{lowPrice}
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值