<select id="selectOrdersByStatesSelective" resultMap="AllResultMap" >
select
<include refid="All_Column_List" />
from order_list
LEFT JOIN product_method ON product_method.`code` = order_list.purchase_method
LEFT JOIN product_color ON product_color.`code` = order_list.color
LEFT JOIN product_guarantee ON product_guarantee.`code` = order_list.guarantee
LEFT JOIN product_info ON order_list.product_id = product_info.id
LEFT JOIN product_model ON product_info.model = product_model.`code`
LEFT JOIN product_standard ON product_info.standard = product_standard.`code`
LEFT JOIN product_state ON product_state.`code` = order_list.order_state
LEFT JOIN product_apperance ON product_apperance.`code` = order_list.apperance
LEFT JOIN product_brand ON product_brand.`code` = product_info.brand
<where>
<if test="order.orderNum != null " >
order_num like "%"#{order.orderNum,jdbcType=VARCHAR}"%"
<if test="order.operator != null " >
and operator like "%"#{order.operator,jdbcType=VARCHAR}"%"
<if test="order.purchaseTime != null" >
and purchase_time = #{order.purchaseTime,jdbcType=DATE}
<if test="order.orderState != null" >
and order_state = #{order.orderState,jdbcType=VARCHAR}
<if test="order.serialNum != null" >
and serial_num like "%"#{order.serialNum,jdbcType=VARCHAR}"%"
<if test="states != null and states.length >0">
<foreach collection="states" item="state" separator="," open=" and order_state in (" close=")">
#{state,jdbcType=BIGINT}
</foreach>
</where>
</select>