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>
相关推荐
灯澜忆梦16 小时前
【MySQL10】进阶篇 | 索引_#1
数据库·sql·mysql
敲上瘾16 小时前
redis常用数据类型与操作方法
数据结构·数据库·redis·缓存
OceanWaves199316 小时前
mysql 5.7.29 主从同步配置
数据库·mysql·adb
molaoye16 小时前
win10下切换MySQL版本
数据库·mysql
丁引16 小时前
《数据清洗的艺术:如何用20行核心逻辑优雅地删除无标签图片》
前端·数据库·python
雨辰AI16 小时前
K8s 数据库 Secret 加密实战|密码明文漏洞彻底修复,等保密评双合规(金仓 / 达梦双库适配)
数据库·容器·kubernetes
c2385617 小时前
MySQL 基础用法(下):查询进阶与核心特性
android·c语言·c++·mysql
XR12345678817 小时前
学校图书馆网络改造,方案谁更优?
网络·数据库·php
梦想的旅途217 小时前
企业微信自动化:自动发送文本、图片、文件
前端·数据库·microsoft
IvorySQL17 小时前
PostgreSQL 日报|复制槽泄漏修复(8 月 6 日)
数据库·postgresql