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>
相关推荐
清水白石0084 分钟前
装饰器模式 vs Python 装饰器:同名背后的深度解析与实战融合
数据库·python·装饰器模式
正在走向自律5 分钟前
文档数据库替换新范式:金仓数据库MongoDB兼容性深度解析与实践指南
数据库·mongodb·国产数据库·金仓数据库
陈桴浮海12 分钟前
MySQL 主从复制与 GTID 环形复制
linux·mysql·云原生
坐吃山猪14 分钟前
Neo4j02_CQL语句使用
运维·服务器·数据库
“αβ”20 分钟前
MySQL数据类型
c语言·数据库·opencv·mysql·数据挖掘·数据类型·数据
MMME~27 分钟前
HAProxy:高性能负载均衡实战指南
linux·运维·数据库
難釋懷39 分钟前
基于Redis的Stream结构作为消息队列,实现异步秒杀下单
数据库·redis·缓存
TDengine (老段)42 分钟前
TDengine IDMP 数据可视化——状态时间线
大数据·数据库·ai·信息可视化·时序数据库·tdengine·涛思数据
DolphinDB智臾科技42 分钟前
V3.00.5 & 2.00.18 更新!TPC-H 性能跃升,MPP 引擎来了…
大数据·数据库·时序数据库·dolphindb
xing-xing42 分钟前
Spring Data项目
数据库·spring