MyBatis的mapper.xml中对于一个传参的多重判断

 MyBatis中的mapper.xml中对于一个传递参数的多重判断 

《where>
    <if test="stockOrderNum!=null">
        <if test='stockOrderNum=="0"'>
            and mt.stock_order_id is null
        </if>
        <if test='stockOrderNum=="1"'>
            and mt.stock_order_id is not null
            and length(mt.stock_order_id)-length(replace(mt.stock_order_id,';','')) = 0
        </if>
        <if test='stockOrderNum=="2"'>
            and mt.stock_order_id is not null
            and  length(mt.stock_order_id)-length(replace(mt.stock_order_id,';','')) >= 1
        </if>
    </if>
</where>

猜你喜欢

转载自blog.csdn.net/y_bccl27/article/details/113986993