如何在mapper文件中使用in("str1","str2")
作者:懒惰的小蜗牛 时间:2023-07-10 10:40:51
mapper文件使用in("str1","str2")
mybatis的xxxMapper.xml文件中,如果筛选的字段使用的是varchar类型,在xml中需要对遍历做处理,在遍历的字段外加‘’
xml
select * from table_name
<where>
del_flg = 1
<if test="statuses != null and statuses.size() > 0 ">
and status in
<foreach collection="statuses" close=")" open="(" item="item" separator=",">
-- 此处添加单引号
'${item}'
</foreach>
</if>
</where>
小细节记录下来,方便后续查看
mapper.xml中sql使用 in 执行失败的原因
mapper.xml传参如果下
user_obj_id in ( #{ids})
最终执行的sql拼接如下
user_obj_id in ( ‘55,56,57' )
而不是期望的
user_obj_id in ( ‘55',‘56',‘58' )
来源:https://blog.csdn.net/qq_41070393/article/details/81484949
标签:mapper,in,str1,str2
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
IDEA查看Scala的源码的教程图解
2023-12-13 22:50:45
![](https://img.aspxhome.com/file/2023/6/105946_0s.png)
java中类与对象的使用详情
2023-09-27 17:10:43
java获取当前时间和前一天日期(实现代码)
2023-09-17 07:48:35
C++数组的定义详情
2023-07-21 08:00:49
![](https://img.aspxhome.com/file/2023/7/127517_0s.png)
Spring MVC的web.xml配置详解
2023-08-10 04:45:01
![](https://img.aspxhome.com/file/2023/0/118910_0s.png)
java利用Future实现多线程执行与结果聚合实例代码
2023-09-24 11:07:18
java读取ftp中TXT文件的案例
2022-07-07 20:10:11
![](https://img.aspxhome.com/file/2023/1/101771_0s.jpg)
Java读取.properties配置文件方法示例
2023-08-24 16:32:56
![](https://img.aspxhome.com/file/2023/9/58159_0s.png)
kotlin 定义接口并实现回调的例子
2022-12-06 14:30:19
![](https://img.aspxhome.com/file/2023/2/103902_0s.jpg)
Android读取assets目录下的所有图片并显示的方法
2023-03-09 22:06:30
使用C语言编写基于TCP协议的Socket通讯程序实例分享
2023-07-05 03:30:03
Android RetainFragment状态保存的方法
2023-06-03 03:35:08
android 控件同时监听单击和双击实例
2022-11-16 15:45:33
![](https://img.aspxhome.com/file/2023/7/87317_0s.jpg)
Android Activity的启动过程源码解析
2023-12-25 11:16:00
![](https://img.aspxhome.com/file/2023/4/138514_0s.png)
java实现一个简单的网络爬虫代码示例
2021-08-05 13:59:12
对Java ArrayList的自动扩容机制示例讲解
2022-04-09 07:58:25
浅谈Java8 判空新写法
2023-06-21 15:55:08
![](https://img.aspxhome.com/file/2023/2/75712_0s.jpg)
Java 实战项目锤炼之网上商城系统的实现流程
2022-06-26 17:21:47
![](https://img.aspxhome.com/file/2023/3/97983_0s.jpg)
C语言字符串另类用法的实现
2023-06-19 02:05:25
Java中方法的重写与成员变量的隐藏
2023-06-01 01:35:55