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>
相关推荐
GIS数据转换器6 分钟前
无人机车载巡检系统
大数据·数据库·人工智能·数据挖掘·数据分析·无人机
AOwhisky8 小时前
MySQL 学习笔记(第四期):SQL 语言之多表查询
linux·运维·网络·数据库·笔记·学习·mysql
小红卒8 小时前
mysql之udf提权
数据库·mysql·网络安全
Trouvaille ~9 小时前
【Redis篇】Redis 哨兵(Sentinel):高可用自动故障转移
数据库·redis·缓存·中间件·sentinel·高可用·哨兵
qfljg9 小时前
oracle 迁移到postgres
数据库·oracle
giaz14n9X9 小时前
Redis 分布式锁进阶第五十七篇
数据库·redis·分布式
剑神一笑10 小时前
Linux ls 命令深度解析:从目录遍历到颜色输出的实现原理
linux·服务器·数据库
Maynor99610 小时前
Codex API 网关迁移与流量优化实战
数据库·oracle
WyCAGy8ij10 小时前
Redis 分布式锁进阶第二篇讲解
数据库·redis·分布式
南极企鹅10 小时前
MySQL的两大支柱:undo Log&redo log
数据库·mysql·oracle