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>
相关推荐
Sirens.15 分钟前
MySQL表设计进阶-约束范式连接索引与事务
android·数据库·mysql
字节跳动开源2 小时前
火山引擎开源 Agent 驱动的搜索自迭代技术
数据库·开源·agent
Oo大司命oO4 小时前
藏在正则表达式里的陷阱
数据库·mysql·正则表达式
_oP_i5 小时前
mysql统计数据库使用存储大小
数据库
会编程的土豆5 小时前
MySQL 入门:库、表、行、主键是什么
linux·数据库·网络协议·http
jjjava2.05 小时前
系统日志:从入门到精通的完整指南
网络·数据库
写代码的强哥5 小时前
云原生数据库与传统数据库相比“新”在哪里
数据库·云原生·架构
吴声子夜歌6 小时前
MongoDB 4.2——查询
数据库·mongodb
三十岁老牛再出发7 小时前
07.26每日总结
linux·c语言·mysql