mysql的in多个条件用法

参考:https://geek-docs.com/mysql/mysql-ask-answer/1345_mysql_mysql_in_clauses_trying_to_match_in_list_of_tuples.html

批量单个条件时,直接用in查询就行,一样会走索引

批量多个条件时,也可以用in ,mybatis写法示范如下

复制代码
/**
 * 查询用户池信息
 * @param list 请求参数
 * @return 用户池信息列表
 */
List<UserPool> batchGet(@Param("list") List<UserPoolSaveRequestDto> list);

xml写法

复制代码
<select id="batchGet"  resultMap="BaseResultMap">
    select <include refid="Base_Column_List" />
    from user_pool
    where deleted = 0
    and (user_code, organization_code) in
    <foreach collection="list" item="item" open="(" close=")" separator=",">
        (#{item.userCode,jdbcType=VARCHAR}, #{item.organizationCode,jdbcType=VARCHAR})
    </foreach>
</select>
相关推荐
寻星探路25 分钟前
数据库造神计划第九天---增删改查(CRUD)(5)
数据库
Alan521591 小时前
🚀 阿里云 ECS + MySQL 环境搭建全流程(用于个人博客系统开发)
数据库·程序员
Huhbbjs1 小时前
SQL 核心概念与实践总结
开发语言·数据库·sql
wuyunhang1234561 小时前
Redis---集群模式
数据库·redis·缓存
sensenlin911 小时前
Mybatis中SQL全大写或全小写影响执行性能吗
数据库·sql·mybatis
会飞的架狗师1 小时前
【MySQL体系】第1篇:从MySQL架构原理到存储的解析
后端·mysql
BXCQ_xuan2 小时前
软件工程实践四:MyBatis-Plus 教程(连接、分页、查询)
spring boot·mysql·json·mybatis
IAtlantiscsdn2 小时前
Redis Stack扩展功能
java·数据库·redis
没有bug.的程序员3 小时前
Redis 大 Key 与热 Key:生产环境的风险与解决方案
java·数据库·redis·缓存·热key·大key
王维志3 小时前
LiteDB详解
数据库·后端·mongodb·sqlite·c#·json·database