mybatis查询配置文件中关于 in 的条件查询
2017-07-26 10:37
393 查看
1.dao层 条件参数Map中传入String[] 字符串数组
2.dao对应的sql.xml中 in 查询写法如下:
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>
相关文章推荐
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
- mybatis的sql的xml的配置文件中where条件中in的用法。
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
- 使用mybatis遇到的关于条件查询">"以及if test传参的使用问题
- mybatis框架配置文件之联表查询
- mybatis mapper.xml文件中配置提示如下错误The entity name must immediately follow the '&' in the entity reference
- 【MyBatis框架】mapper配置文件-关于动态sql
- 【MyBatis框架】mapper配置文件-关于动态sql
- 关于where的条件查询in
- Mybatis中查询的参数为Map条件中是in 数据组参数
- mybatis 查询多个条件IN的使用方法
- hibernate条件查询注入自定义Bean无需配置文件,取需要的字段
- Mybatis查询实例,sql中的in在Mybatis中怎么写--以list为查询条件
- mybatis的sql的xml的配置文件中where条件中like的用法。
- hibernate条件查询注入自定义Bean无需配置文件,取需要的字段
- 关于Spring与mybatis整合无法读取配置文件的问题
- 关于配置XML的异常分析-Mybatis配置文件
- MyBatis中的in条件查询的用法代码示例
- 【MyBatis框架】mapper配置文件-关于动态sql
- mybatis-config.xml配置文件及sql分页查询的实现