xiaowei8782088 发表于 2016-11-26 10:20:21

mybatis foreach标签模糊查询

<select id="searchByRouteStatus"parameterType="java.util.Map" resultMap="BaseResultMapExt">
select
<include refid="Base_Column_List_Ext" />
from "t_tourist_route" tr
<where>
tr.status_id in
<!--statusList 为map中的键值-->
<foreach close=")" collection="statusList" item="item" open="("
separator=",">
#{item}
</foreach>
<if test="departureDate!=null">
<if test="returnDate!=null">
and tr.departure_date BETWEEN #{departureDate} AND
#{returnDate}
</if>
</if>
<if test="routeName!=null">
and tr.route_name like '%'||#{routeName}||'%'
</if>
<if test="routeNumber!=null">
and tr.route_number like '%'||#{routeNumber}||'%'
</if>
</where>
</select>
 
页: [1]
查看完整版本: mybatis foreach标签模糊查询