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>
相关推荐
zfoo-framework2 小时前
线上redis的使用
数据库·redis·缓存
IT-david2 小时前
MySQL分析步
mysql
典孝赢麻崩乐急2 小时前
Redis学习-----Redis的基本数据类型
数据库·redis·学习
止水编程 water_proof3 小时前
MySQL——事务详解
数据库·mysql
爱喝水的鱼丶4 小时前
SAP-ABAP:SAP ABAP OpenSQL JOIN 操作权威指南高效关联多表数据
运维·开发语言·数据库·sap·abap
m0_653031364 小时前
一套视频快速入门并精通PostgreSQL
数据库·postgresql
不似桂花酒4 小时前
数据库小知识
数据库·sql·mysql
ZZH1120KQ4 小时前
ORACLE的表维护
数据库·oracle
典孝赢麻崩乐急4 小时前
数据库学习------数据库事务的特性
数据库·学习·oracle
杜哥无敌4 小时前
在SQL SERVER 中,用SSMS 实现存储过程的每日自动调用
数据库