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>
相关推荐
盟接之桥8 分钟前
盟接之桥谈线束数字化-按单入按单出:线束企业库存管理的破局之道
大数据·前端·网络·数据库·人工智能·制造
我不会起名字32221 分钟前
MySQL 深分页 LIMIT 1000000 卡死:3 种改写与 4 组实测对比
mysql·性能优化·索引·分页·limit
Nturmoils30 分钟前
数据集成软件 KFS:多套业务库汇聚时,先把来源和口径理清
数据库
麦壳饼39 分钟前
SonnetDB:批量写入的大小、背压与刷新策略
数据库·sonnetdb
weixin_460443561 小时前
Java+Linux私有化训考平台:服务、数据库与终端部署结构解析
java·linux·数据库·私有化部署·企业培训考试系统·企业考试系统
编程火箭车2 小时前
MySQL 拥抱 AI:向量、RAG、AutoML 全进了数据库
数据库·mysql·ai编程·向量数据库·rag·automl·mysql9
o_oer2 小时前
mysql type
mysql
花卷持续成长2 小时前
慢SQL的整体优化思路
后端·mysql
用户8662978480082 小时前
KingbaseES 中文乱码、排序不对?区域和字符集的问题,一次说清
数据库
aruo2 小时前
回退旧镜像之前,先确认数据库还能兼容
数据库