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>
相关推荐
ao-weilai19 分钟前
MySQL数据库:内置函数
android·数据库·mysql
LaughingZhu22 分钟前
Product Hunt 每日热榜 | 2026-10-02
数据库·人工智能·深度学习·神经网络·搜索引擎
天疆说1 小时前
腾讯会议 Linux 版在 NVIDIA 显卡上看不到画面:EGL 像素配置与窗口视觉不匹配的排查与修复
linux·数据库·腾讯会议
2603_969579281 小时前
中小团队数据库选型:MySQL vs PostgreSQL,业务场景怎么选
数据库·mysql·postgresql
IT大白鼠2 小时前
图数据库系列 · 第 06 篇——避坑汇总:经典生产问题
数据库·nosql·图库数据库
江湖有缘2 小时前
3开源Sqlite数据库管理工具整理合集,可Docker一键部署!
数据库·sqlite·开源
jyOverQ2 小时前
Redis 持久化怎么做?RDB、AOF 与混合持久化
数据库·redis
j7~2 小时前
【C++ 标准项目】发布订阅消息队列(篇四):sqlite 与 gtest 断言框架介绍及实战应用
数据库·sqlite·gtest·断言·事件机制·tset宏
于指尖飞舞2 小时前
mysql和redis面试题总结
数据库·redis·mysql