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>
相关推荐
Bert.Cai5 小时前
MySQL LPAD()函数详解
数据库·mysql
OnlyEasyCode6 小时前
Navicat 任务自动备份指定数据库
数据库
if else6 小时前
Redis 哨兵集群部署方案
数据库·redis
yejqvow127 小时前
Pandas 高效实现组内跨行时间戳匹配与布尔标记
jvm·数据库·python
了不起的云计算V7 小时前
从DeepSeek V4适配看国产算力的三个拐点
数据库·人工智能
qq_189807037 小时前
html标签如何提升可访问性_aria-label与title区别【指南】
jvm·数据库·python
norq juox7 小时前
MySQL 导出数据
数据库·mysql·adb
qq_349317487 小时前
mysql如何设置定时自动备份脚本_编写shell脚本与cron任务
jvm·数据库·python
952368 小时前
Spring IoC&DI
java·数据库·spring
尚雷55808 小时前
从电商订单支付更新,吃透 Oracle 数据修改的底层设计哲学与全组件协同原理
数据库·oracle