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>
相关推荐
高梦轩4 小时前
MySQL高可用
android·运维·数据库
紫金修道7 小时前
【DeepAgent】概述
开发语言·数据库·python
孟章豪7 小时前
《SQL拼接 vs 参数化,为什么公司禁止拼接SQL?(附真实案例)》
服务器·数据库·sql
荒川之神7 小时前
ORACLE LEVEL函数练习
数据库·oracle
·云扬·8 小时前
【MySQL】实战:用pt-table-sync修复主从数据一致性问题
数据库·mysql·ffmpeg
swIn KWAL8 小时前
【MySQL】环境变量配置
数据库·mysql·adb
shark22222228 小时前
【JOIN】关键字在MySql中的详细使用
数据库·mysql
RATi GORI8 小时前
MySQL中的CASE WHEN语句:用法、示例与解析
android·数据库·mysql
坊钰8 小时前
Java 死锁问题及其解决方案
java·开发语言·数据库
onebound_noah9 小时前
【实战教程】如何通过API快速获取淘宝/天猫商品评论数据(含多语言Demo)
大数据·数据库