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>
相关推荐
APguantou33 分钟前
NCRE-三级数据库技术-第2章-需求分析
数据库·需求分析
寂夜了无痕1 小时前
MySQL 主从延迟全链路根因诊断与破局法则
数据库·mysql·mysql主从延迟
爱丽_1 小时前
分页为什么越翻越慢:offset 陷阱、seek 分页与索引排序优化
数据库·mysql
APguantou1 小时前
NCRE-三级数据库技术-第12章-备份与数据库恢复
数据库·sqlserver
Bat U1 小时前
MySQL数据库|表设计+新增+分组查询
数据库·mysql
麦聪聊数据2 小时前
企业数据流通与敏捷API交付实战(五):异构数据跨库联邦与零代码发布
数据库·sql·低代码·restful
Elastic 中国社区官方博客2 小时前
当 TSDS 遇到 ILM:设计不会拒绝延迟数据的时间序列数据流
大数据·运维·数据库·elasticsearch·搜索引擎·logstash
qing222222222 小时前
Linux中修改mysql数据表
linux·运维·mysql
Omics Pro2 小时前
虚拟细胞:开启HIV/AIDS治疗新纪元的关键?
大数据·数据库·人工智能·深度学习·算法·机器学习·计算机视觉
J2虾虾2 小时前
MySQL的基本操作
数据库·mysql