MyBatis之mapper.xml如何对传参进行多次判断呢?
下文笔者讲述mybatis中对mapper.xml进行多次判断的方法及示例分享
mapper.xml进行多次判断的实现思路
只需在if 中嵌套if
即可实现多重判断的效果
例:mapper中多重判断的示例
<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>
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


