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>
相关推荐
WJB-DavidWang几秒前
MongoDB-非关系型数据库-文档数据库(三) Kafka测试MongoDB性能
数据库·mongodb·nosql
m0_678485453 分钟前
c++如何提取系统环境变量并直接保存到txt日志中_getenv与ofstream【实战】
jvm·数据库·python
lKWO OMET6 分钟前
查看 nginx 是否已经启动
运维·数据库·nginx
qq_342295827 分钟前
Go语言怎么嵌入静态文件_Go语言embed嵌入文件教程【秒懂】
jvm·数据库·python
qq_2069013912 分钟前
如何在Linux上源码编译安装MySQL_CMake配置与依赖包安装
jvm·数据库·python
2401_8716965220 分钟前
CSS如何解决Flex布局在老版本安卓机兼容性_使用autoprefixer工具
jvm·数据库·python
qq_2069013921 分钟前
c++怎么把多个变量一次性写入二进制文件_结构体对齐与write【实战】
jvm·数据库·python
weixin_5806140021 分钟前
golang如何给图片添加水印_golang图片添加水印解析
jvm·数据库·python
Shorasul21 分钟前
mysql如何进行表空间传输恢复_mysql transport tablespace实战
jvm·数据库·python
解救女汉子25 分钟前
golang如何实现群聊功能_golang群聊功能实现策略
jvm·数据库·python