当前位置:网站首页>Mybats foreach multi select query, index loop, and cancel the and/or tag
Mybats foreach multi select query, index loop, and cancel the and/or tag
2022-07-28 05:30:00 【wang0112233】
demand : Field is an array , Select multiple from the front-end drop-down code List to query
analysis : If it is a single field, you can use in Inquire about , If mysql The version is 5.7 The above words can be used JSON Function query , Because the local database version is 5.6, I won't support it JSON function , So use like Inquire about
Because of the pull-down code Is a union , So use OR Inquire about , Use to <foreach> label
Default code <foreach> It's usually
<if test="query.brCode != null and query.brCode.size() > 0">
and (
<foreach collection="query.brCode" index="index" item="item">
or rr.b_list LIKE CONCAT('%',#{item},'%')
</foreach>
)
</if>After that, we need to cancel the first or label , The thought of idnex The role of
Final realization :
<if test="query.brCode != null and query.brCode.size() > 0">
and (
<foreach collection="query.brCode" index="index" item="item">
<if test="index != 0 ">
or
</if>
br_list LIKE CONCAT('%',#{item},'%')
</foreach>
)
</if>Have a problem :
mybaties java.lang.NumberFormatException: For input string: "{0=null}"
Because it has just been used #{index} Lead to
边栏推荐
- JVM note 4: Memory Model
- Implementation of simple upload function in PHP development
- Interpretation of afnetworking4.0 request principle
- Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions
- Why is MD5 irreversible, but it may also be decrypted by MD5 free decryption website
- ES6 new variable modifiers let and const, new basic data type symbol
- 多线程进阶:synchronized底层原理,锁优化、锁升级的过程
- You must configure either the server or JDBC driver (via the ‘serverTimezone)
- Printf function of input and output function in C language
- Duoyu security browser will improve the security mode and make users browse more safely
猜你喜欢

Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions

ByteBuffer.position 抛出异常 IllegalArgumentException

First acquaintance with C language (2)

【idea插件神器】教你如何使用IDEA一键set实体类中所有属性

Scanf function of input and output function in C language

VMware Workstation 与 Device/Credential Guard 不兼容。禁用 Device/Credential Guard

You must configure either the server or JDBC driver (via the ‘serverTimezone)

From the basic concept of micro services to core components - explain and analyze through an example

FreeRTOS personal notes - task notification

How practical is the struct module? Learn a knowledge point immediately
随机推荐
ByteBuffer. Position throws exception illegalargumentexception
Mabtis(一)框架的基本使用
Long和Integer如何进行比较,为什么报错
New arrow function in ES6
集合框架的操作使用
【CVPR2022】Multi-Scale High-Resolution Vision Transformer for Semantic Segmentation
[computer level 3 information security] overview of information security assurance
多线程进阶:synchronized底层原理,锁优化、锁升级的过程
Redis 之布隆过滤器
FusionGAN代码学习(一)
关于swagger中的localDateTime
Response < t > class
2021CSDN博客之星评选,互投
数据库面试
Microservice failure mode and building elastic system
Mysql处理遗留数据样例
PC side bug record
项目中问题合集
子父线程交互
JMeter related knowledge sorting