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 升到 8.4 前的兼容性自检清单
mysql
IT古董2 小时前
《FDE前沿部署工程师实战教程》33 - Enterprise AI Observability:从Agent Trace到全链路智能运维
数据库·人工智能
for_ever_love__2 小时前
MySQL 主从复制讲透:binlog 原理、搭建步骤与读写分离
java·数据库·mysql·binlog·读写分离·原理·主从复制
Nturmoils6 小时前
GROUP BY 先别想当然,查汇总前把规则跑清楚
数据库
最笨的羊羊7 小时前
Oceanbase数据库系列之:向量数据库核心知识
数据库·oceanbase
fish_xk7 小时前
mysql中的表的约束
数据库·mysql
谢亮_vipxieliang7 小时前
Go Channel 高级模式——从底层原理到扇出扇入实战
java·数据库·golang
ggaofeng8 小时前
自己编写邮件服务器和客户端
数据库
java1234_小锋8 小时前
【技术专题】Mysql8 数据库 - Mysql8 添加,更新,删除数据
数据库·mysql
PaperData8 小时前
2015-2024年各省绿色贸易数据
数据库