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>
 

 

你可能感兴趣的:(mybatis)