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>
相关推荐
就叫_这个吧5 小时前
Redis从基础命令到核心机制简单介绍
数据库·redis·缓存
三十岁老牛再出发5 小时前
07.27&7.28每日总结
c语言·mysql
dear_bi_MyOnly5 小时前
【MyBatis 操作数据库】
java·数据库·学习·mybatis·学习方法
DBA_G6 小时前
南大通用GBase 8s数据库新存储引擎核心能力二
数据库·微服务·架构
衣乌安、8 小时前
数据库事务原理与回滚机制
数据库
CodexDave9 小时前
PostgreSQL 明明有索引却选了 Nested Loop:从行数误判修正执行计划
数据库·postgresql·执行计划·扩展统计·nestedloop
czhaii10 小时前
STC ai助手单片机工程项目创建实例
数据库·mongodb
山峰哥10 小时前
数据库性能救星:Explain执行计划深度拆解
服务器·开发语言·数据库·sql·启发式算法
oradh11 小时前
Oracle 11g rac IP地址修改(public ip、vip、scan ip、priviate ip)
数据库·tcp/ip·oracle·rac ip地址修改
YOU OU11 小时前
Redis哨兵 & 集群
数据库·redis·sentinel