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>
相关推荐
ZTLJQ2 小时前
数据的基石:Python中关系型数据库完全解析
开发语言·数据库·python
升鲜宝供应链及收银系统源代码服务2 小时前
《IntelliJ + Claude Code + Gemini + ChatGPT 实战配置手册升鲜宝》
java·前端·数据库·chatgpt·供应链系统·生鲜配送
跟着珅聪学java3 小时前
js编写中文转unicode 教程
前端·javascript·数据库
小江的记录本3 小时前
【Redis】Redis全方位知识体系(附《Redis常用命令速查表(完整版)》)
java·数据库·redis·后端·python·spring·缓存
还是做不到嘛\.3 小时前
Dvwa靶场-SQL Injection
数据库·sql·web安全
楼田莉子4 小时前
MySQL数据库:MySQL的数据类型
数据库·学习·mysql
2401_879693874 小时前
数据分析与科学计算
jvm·数据库·python
LJianK15 小时前
java封装
java·前端·数据库
知识分享小能手5 小时前
MongoDB入门学习教程,从入门到精通,MongoDB查询(4)
数据库·学习·mongodb
LSL666_6 小时前
MybatisPlus条件构造器(上)
java·数据库·mysql·mybatisplus