mybatis list 作为模糊查询的参数 ,(还有其他的参数)
select * from app_rule
<where>
<if test="risks!=null and risks.size()>0">
and risk in
<foreach collection="risks" open="(" close=")" separator="," item="type">
#{type}
</foreach>
</if>
<if test="chtcs!=null and chtcs.size()>0">
and
<foreach collection="chtcs" open="(" close=")" separator="and" item="type">
chtc like '%${type}%'
</foreach>
</if>
</where>
注意点:拼字符串 占位符用 $, and 卸载外面。
mybatis list 作为模糊查询的参数 无其他参数
select * from app_rule
<where>
<if test="chtcs!=null and chtcs.size()>0">
<foreach collection="chtcs" open="(" close=")" separator="and" item="type">
and chtc like '%${type}%'
</foreach>
</if>
</where>