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>
相关推荐
新法国菜1 小时前
MySql知识梳理之DML语句
数据库·mysql
老华带你飞1 小时前
校园交友|基于SprinBoot+vue的校园交友网站(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·校园交友网站
许泽宇的技术分享1 小时前
Text2API与Text2SQL深度对比:自然语言驱动的数据交互革命
数据库·windows·microsoft
两张不够花4 小时前
Shell脚本源码安装Redis、MySQL、Mongodb、PostgreSQL(无报错版)
linux·数据库·redis·mysql·mongodb·postgresql·云计算
Java 码农5 小时前
nodejs 集成mongodb实现增删改查
数据库·mongodb
少陵野小Tommy5 小时前
Python能用古诗词数据库做什么7:根据标题、诗句查找诗歌
开发语言·数据库·python
花花无缺6 小时前
MySQL--B+树
后端·mysql
khystal7 小时前
HUMS 2023齿轮箱数据分析
数据库·数据分析·信号处理
Warren987 小时前
Spring Boot 整合网易163邮箱发送邮件实现找回密码功能
数据库·vue.js·spring boot·redis·后端·python·spring