Mybatis实现in查询(注解形式和xml形式)
2018-01-12 15:40
471 查看
1. @Select注解中使用in
2. xml中使用in
@Select({"<script> " + " select * "+ " from business_threat bt \n" + " join abnormal_event_type aet on bt.event_type_id = aet.id " + " where 1=1 " + " <if test = \" ids != null \"> " + " and bt.id in " + " <foreach item = 'item' index = 'index' collection = 'ids' open = '(' separator = ',' close = ')' > " + " #{item} " + " </foreach> " + " </if> " + "</script>"}) List<BusinessThreatVO> getByBusinessThreadId(@Param("ids") List<Long> ids);
2. xml中使用in
<select id="findByModelInMarket" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from device WHERE replace(lower(model_in_market), ' ', '') = replace(lower(#{modelInMarket}), ' ', '') AND status IN <foreach collection="deviceStatus" item="status" open="(" close=")" separator=",">#{status}</foreach> </select>
相关文章推荐
- mybatis 用注解实现 in 查询
- 第二章 mybatis使用注解实现in查询(mysql)
- 第二章 mybatis使用注解实现in查询(mysql)
- mybatis09(注解实现多对一的查询)
- mybatis-config.xml配置文件及sql分页查询的实现
- mybatis使用foreach语句实现IN查询
- SSM框架-Mybatis基于注解实现增删查改和多参数列表查询
- mybatis学习笔记(二)-- 使用mybatisUtil工具类体验基于xml和注解实现
- Mybatis基于注解实现增删查改和多参数列表查询
- Mybatis基于注解实现增删查改和多参数列表查询
- Mybatis List列表In查询实现的注意事项
- SpringBoot入门-19(springboot集成mybatis注解形式增删查改properties配置,利用《script》实现动态SQL)
- 源码解读Mybatis List列表In查询实现的注意事项
- mybatis实现in传入数组查询
- mybatis使用foreach实现sql的in查询
- mybatis3通过provider注解结合动态sql实现增删改查,不再依赖xml成为可能
- spring boot 整合mybatis 中用注解实现的查询
- 源码解读Mybatis List列表In查询实现的注意事项
- 源码解读Mybatis List列表In查询实现的注意事项
- 3、Mybatis通过注解的形式实现增、删、改、查