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>
相关推荐
上学的小垃圾3 小时前
基于docker安装MySQL(openEuler系统)
linux·mysql·docker·容器
倔强的石头_4 小时前
连接数失控排查:从数据库会话、应用线程池到连接池泄漏
数据库
hzxpaipai5 小时前
企业官网技术架构拆解:前端、后台、数据库、服务器如何协同
前端·数据库·架构
爱吃火鸡面呀6 小时前
MySQL DQL 子查询详解:从标量、列、行到表子查询的完整实战
大数据·数据库·mysql
harmony&6 小时前
OpenStack 云平台管理实战:从 Keystone 认证到 Nova 计算调度
数据库·openstack
betazhou7 小时前
Apache Seatunnel 抽取Oracle数据库测试
数据库·oracle·apache·seatunnel
devilnumber8 小时前
Oracle 与 MySQL substr 函数差异总结
java·数据库·mysql·oracle
—Miss. Z—9 小时前
计算机等级考试三级数据库技术—选择题
数据库·mysql
www_aiyuanma_vip9 小时前
PC 手机电商(MySQL 版)
数据库·mysql·智能手机