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>
相关推荐
gwf21633 分钟前
磨损均衡算法(Wear Leveling)——SSD如何让每块闪存“公平退休“?
运维·数据库·人工智能·python·嵌入式硬件·算法·智能硬件
AAA@峥38 分钟前
CentOS7 源码编译安装 MySQL5.7|SQL 基础操作 + 备份恢复完整实战
运维·数据库·sql·centos
xixingzhe240 分钟前
spring ai简单使用skills
数据库·人工智能·spring
Fu2067211 小时前
数据库第三次作业
数据库
AI多Agent协作实战派2 小时前
AI多Agent协作系统实战(二十三):Agent读HEARTBEAT.md不读AGENTS.md——openclaw的文件加载之谜
前端·数据库·人工智能·uni-app
一嘴一个橘子2 小时前
MysqL 哪些情况适合创建索引
mysql
jun_bai2 小时前
postgresql数据库免安装版安装到windows系统
数据库·postgresql
weixin_538601972 小时前
智能体测开Day33
数据库·oracle
时间的拾荒人2 小时前
MySQL C语言连接 - 从入门到实战
android·c语言·mysql
番茄炒鸡蛋加糖2 小时前
Redis--Lua 脚本原子性与滑动窗口限流
数据库·redis·lua