您的位置:首页 > 其它

mybatis查询配置文件中关于 in 的条件查询

2017-07-26 10:37 393 查看
1.dao层 条件参数Map中传入String[] 字符串数组

HashMap<String,Object> paramsMap=new HashMap<String,Object>();
String[] strArr={"1","2"};
paramsMap.put("deptIds",strArr );
List list=dao.findList(paramsMap);


2.dao对应的sql.xml中 in 查询写法如下:

<select id="findList" resultType="HashMap" parameterType="HashMap">
select dept_id,dept_name from table A
<where>
<if test="deptIds != null and deptIds!=''">
AND A.DEPT_ID IN
<foreach item="item" index="index" collection="deptIds"   open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐