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>
相关推荐
Leon-Ning Liu24 分钟前
【真实经验分享】 ORA-600 [qesmaGetTblSeg1]
数据库·oracle
与数据交流的路上26 分钟前
MySQL 优化 -- 相关
数据库·mysql
Rooting++38 分钟前
为什么mysql的表字段的collation会自动变
数据库·mysql
Wch1G0z8A39 分钟前
Google 开源了啥,让 AI Agent 碰数据库不再是定时炸弹
数据库·人工智能·开源
tedcloud1231 小时前
cc-switch评测:多AI Coding Agent管理工具详解
数据库·人工智能·sql·学习·自动化
土狗TuGou1 小时前
SQL内功笔记 · 第8篇:事务的四大特性与隔离级别
数据库·笔记·后端·sql·mysql·oracle
流星白龙1 小时前
【MySQL高阶】10.MySQL架构,连接层服务层
mysql
Nturmoils2 小时前
一台 2C2G 服务器上的 KingbaseES 安装记录
数据库
木头程序员2 小时前
SSM框架学习笔记
java·开发语言·mysql·spring·maven
SelectDB3 小时前
从 Machine-Readable 到 Agent-Ready:面向智能体的数据库接口演进
大数据·数据库·agent