<select id="getOrderSubsByOrderIdOrOutOrderId" parameterType="java.util.Map" resultMap="OrderSubMap"> select * from tbl_order_sub os where <foreach collection="orderSubNos" item="orderSubNo" open="" close="" separator="OR"> os.order_sub_no = #{orderSubNo} </foreach> or <foreach collection="outOrderIds" item="outOrderId" open="" close="" separator="OR"> os.order_sub_no = #{orderSubNo} </foreach> </select>若是要用In語句,以下:
<select id="findByIdsMap" resultMap="BaseResultMap"> Select <include refid="Base_Column_List" /> from jria where ID in <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> #{item} </foreach> </select>