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>
相关推荐
小码农 - 初26 分钟前
MySQL前言
mysql
z落落40 分钟前
StudentInfo表 分页、增删改 存储过程+C# WinForm 存储过程实现分页和增删改查
数据库·sql·mysql
影寂ldy1 小时前
WinForm 数据库【新增+编辑】完整功能(参数化查询+配置文件+防报错全套)
数据库
迷枫7121 小时前
达梦数据库 Hint 使用与 Hint 注入实战
数据库
Gauss松鼠会2 小时前
【GaussDB】GaussDB锁阻塞源头查询
java·开发语言·前端·数据库·算法·gaussdb·经验总结
2601_965798473 小时前
How to Build a Custom Artisan Store on WordPress: Crafti Theme Review
linux·服务器·数据库
霸道流氓气质3 小时前
Spring 事务传播机制与 REQUIRES_NEW
java·数据库·spring
YOU OU3 小时前
Redis分布式锁
数据库·redis·分布式
小草儿7993 小时前
GBase 8s CLOB → VARCHAR(32739) 数据迁移方案文档
数据库
秋田君4 小时前
QT_QColorDialog颜色对话框
java·数据库·qt