空值检索写法

标题

空值检索的解决(也是mybatis xml 的双重if)

                 <li>
                        <label>检查类型:</label>
                        <select name="checkType">
                            <option value=""  th:selected="${checkType == '0'?true:false}">所有</option>
                            <option value="1" th:selected="${checkType == '1'?true:false}">日常检查</option>
                            <option value="2" th:selected="${checkType == '2'?true:false}">专项检查</option>
                            <option value="3" th:selected="${checkType == '3'?true:false}">双随机检查</option>
                            <option value="4" th:selected="${checkType == '4'?true:false}">全项检查</option>
                            <option value="5" th:selected="${checkType == '5'?true:false}">年检</option>
                            <option value="6" th:selected="${checkType == '6'?true:false}">专项整治</option>
                            <option value="7" th:selected="${checkType == '7'?true:false}">其他</option>
                            <option value='True' th:selected="${checkType == 'True'?true:false}">未标记类型</option>
                        </select>
                    </li>

xml 部分写法

    <if test="checkType!=null and checkType!='' and checkType!='True'.toString() ">
        and i.CHECK_TYPE = #{checkType}
   </if>
    
   <if test="checkType!=null and checkType!='' and checkType=='True'.toString() ">
        and i.CHECK_TYPE is null
    </if>

实体中要声明字段true;

空值查询的2种写法ex:

  1. and i.CHECK_TYPE is null
  2. and Isnull(i.CHECK_TYPE) = ‘Ture’
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值