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>
相关推荐
sugar__salt14 小时前
向量数据库从零到实战:用 Milvus + Zilliz 构建 AI 日记语义检索系统
数据库·人工智能·embedding·milvus·rag·zilliz
Gauss松鼠会14 小时前
Prometheus 实现 openGauss 的指标监控(二)Prometheus 中添加 openGauss指标
网络·数据库·oracle·prometheus·opengauss·经验总结
Cloud云卷云舒14 小时前
PolarDB(阿里云)VS HaishanDB(海山数据库,移动云)的AI能力全面对比
数据库·阿里云·ai-native·polardb·haishandb
我是人✓15 小时前
SQL主键与外键
java·数据库
飞翔的馒15 小时前
浏览器缓存之【结构化数据库与缓存】: IndexedDB、Cache storage 和 Storage buckets
数据库·缓存
SelectDB15 小时前
SelectDB search():AI 日志搜索与分析场景的技术能力与实践
数据库
SelectDB15 小时前
Apache Doris 事务保障:技术能力、选型对比与企业实践
数据库
SelectDB15 小时前
AI Observe Stack(基于 Apache Doris):AI Agent 可观测性技术能力、选型对比与实践
数据库
SelectDB15 小时前
PostgreSQL + Apache Doris HTAP 架构:技术能力、选型对比与企业实践
数据库