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>
相关推荐
晚风_END2 小时前
Linux|操作系统|最新版openzfs编译记录
linux·运维·服务器·数据库·spring·中间件·个人开发
dLYG DUMS3 小时前
DBeaver连接本地MySQL、创建数据库表的基础操作
数据库·mysql
苍煜4 小时前
MySQL分库分表和ES到底怎么选?
数据库·mysql·elasticsearch
茉莉玫瑰花茶4 小时前
Qt 信号与槽 [ 1 ]
开发语言·数据库·qt
czlczl200209254 小时前
松散索引扫描/跳跃索引扫描
数据库·mysql·性能优化
苍煜5 小时前
二叉树、红黑树、B树、B+树通俗教学:各自适配场景+MySQL索引终极选型原因
数据结构·b树·mysql
星马梦缘6 小时前
数据库作战记录 实验7、8
数据库·sql·oracle
安逸sgr6 小时前
Hermes Agent + Obsidian 打造第二大脑(六):分层记忆系统的设计逻辑——L0/L1/L2/L3 四层记忆详解
数据库·agent·知识库·hermes·hermesagent
苍煜7 小时前
一篇讲懂分库分表:概念、spirngboot实战
数据库·oracle
梦想画家7 小时前
PostgreSQL 物化视图实战:从数据固化到智能刷新的全链路指南
数据库·postgresql·物化视图