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>
相关推荐
菲兹园长2 小时前
MySql(SQL)
数据库·sql·mysql
一只小bit2 小时前
MySQL表的操作:创建—修改—删除流程解析
数据库·mysql·oracle
做运维的阿瑞2 小时前
PostgreSQL 从入门到精通:Windows 环境下安装与使用指南
数据库·windows·postgresql
学编程的小鬼2 小时前
MySQL的快速入门
数据库·mysql
_Power_Y2 小时前
MySql复习及面试题学习
数据库·学习·mysql
学习编程的Kitty2 小时前
MySQL——数据类型和表的操作
数据库·mysql
程序新视界2 小时前
MySQL中,日期、时间与时间戳三种数据类型的区别
数据库·后端·mysql
lang201509283 小时前
MySQL 8.0性能优化终极指南
数据库·mysql·性能优化
苹果醋33 小时前
数据结构其一 线性表
java·运维·spring boot·mysql·nginx
Elastic 中国社区官方博客3 小时前
在 Elasticsearch 中改进 Agentic AI 工具的实验
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索