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>
相关推荐
张洛闻Eren14 分钟前
MySQL 管理复制拓扑【MySQL第四课】
linux·运维·数据库·mysql
西安景驰电子25 分钟前
《PTP精确时间协议系列》第二篇:工程部署、调试与性能优化
运维·服务器·网络·数据库·windows·性能优化
xrkhy1 小时前
redis-shake的使用windows版本
数据库·windows·redis
小王C语言2 小时前
MySQL 内置函数:日期函数、字符串函数、数学函数、其他函数
数据库·mysql
ClouGence2 小时前
当 AI 开始直接操作数据库,传统数据库管理工具还有必要吗?
数据库·后端·agent
渣渣盟3 小时前
误删数据之后:MySQL、PostgreSQL、Oracle三库紧急恢复完全实操手册
mysql·postgresql·oracle
teak_on_my_way3 小时前
外网通过 Nginx 访问 Doris Stream Load:一次 HTTP 307 疑难排查与完整代理方案
运维·数据库·nginx·http
Hugh-Yu-1301233 小时前
zhangxuefeng-skill配置教程
数据库
布莱克6053 小时前
理解B+树:原理、特性与应用场景
数据结构·数据库·mysql
冰暮流星3 小时前
mysql之排序查询
数据库·mysql