1.if test = “”
2.where 不安全 用
3.choose标签 放在where 标签里 choose 里放 标签
这里when 只会执行一个 如果when 没有成立的走otherwise
select * from oms_order
<where>
<choose>
<when test="memberUsername != null">
and member_username = #{
memberUsername}
</when>
<when test="orderSn != null">
and order_sn = #{
orderSn}
</when>
<otherwise>
and 1=2
</otherwise>
</choose>
</where>
foreach
<select id="selectByOne" resultType="com.zyf.mall.tiny.mbg.model.OmsOrder">
select * from oms_order
<where>
<foreach collection="list1" item="l" open="(" close=")" separator="or">
id = #{
l}
</foreach>
</where>
</select>