java mybatis mapper 中循环查询条件

SELECT
		o.*
	FROM
		u_order o
		LEFT JOIN u_order_goods og ON o.id = og.order_id
<where>
	o.is_virtual = 0
	<if test="uOrderGoodsVO.ccode != null and uOrderGoodsVO.ccode != ''">
		AND o.ccode = #{uOrderGoodsVO.ccode}
	</if>
	<if test="uOrderGoodsVO.cinvdefine3 != null and uOrderGoodsVO.cinvdefine3 != ''">
		AND og.cinvdefine3 = #{uOrderGoodsVO.cinvdefine3}
	</if>
	<if test="uOrderGoodsVO.cinvdefine5List != null and uOrderGoodsVO.cinvdefine5List.size > 0">
		AND og.cinvdefine5 in
		<foreach collection="uOrderGoodsVO.cinvdefine5List" item="item" index="index" open="(" close=")" separator=",">
			#{item}
		</foreach>
	</if>
</where>

posted on 2022-06-24 10:11  何苦->  阅读(683)  评论(0)    收藏  举报

导航