1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| xml 为:普通in用法 <if test="record.typeList != null and record.typeList.size()>0 "> AND type in <foreach collection="record.typeList" open="(" close=")" item="type" separator=","> #{type} </foreach> </if>
sql: and type in(1,2,3)
============================== like foreach: <if test="record.typeList != null and record.typeList.size()>0 "> AND <foreach collection="record.typeList" open="(" close=")" item="type" separator="or"> type like concat('%',#{type},'%') </foreach> </if> sql: and (type like concat('%',1,'%') or type like concat('%',2,'%') or type like concat('%',3,'%') )
|