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>
相关推荐
时间售卖铺12 分钟前
MySQL 表的约束
运维·数据库·mysql·云原生
一条泥憨鱼17 分钟前
【Redis | 黑马点评】基于Redis的消息队列 | stream消息队列 源码解读
java·数据库·redis·缓存·lua
CodeGL17 分钟前
9、Python基础之IO编程
开发语言·数据库·python
每天一道题19 分钟前
Redis 缓存为什么会出问题?穿透、击穿、雪崩与缓存一致性
数据库·redis·缓存
tongyiixiaohuang41 分钟前
物料成本核算单同步返回信息策略实战教程:从金蝶云星空回写 MySQL 的闭环设计
数据库·mysql
星云低代码开发平台1 小时前
AI 工作台记录删除与业务审计留存:三层数据边界设计
数据库·人工智能·架构
深度学习04071 小时前
MySQL InnoDB Cluster 部署完整文档
android·mysql·adb
code_slave(码畜)1 小时前
微服务架构落地:分库分表实战(下) —— 分布式主键、跨分片查询与分页聚合防坑
数据库·spring boot·分布式·spring cloud·微服务·架构·分库分表
dishugj1 小时前
https://blog.csdn.net/dishugj/article/details/162068579
数据库·系统架构
时间售卖铺2 小时前
MySQL 安装部署
运维·数据库·mysql·云原生