SQL 用 in 大于 1000 问题解决
-- 今天生成环境数据突然多,系统异常 解决方案(必须用in 业务情况),也可以用其他函数解决 union all 或者 exists 等
1:截取list
List<Integer> intList1apache=new ArrayLiat();
- List<List<Integer>> subs1apache = ListUtils.partition(intList1apache, 999);
2 :将List<String> 划分为List<List<String>>
按指定大小,分隔集合,将集合按规定个数分为n个部分
private static List<List<String>> splitList(List<String> list, int len) {
if (list == null || list.size() == 0 || len < 1) {
return null;
}
List<List<String>> result = new ArrayList<List<String>>();
int size = list.size();
int count = (size + len - 1) / len;
for (int i = 0; i < count; i++) {
List<String> subList = list.subList(i * len, ((i + 1) * len > size ? size : len * (i + 1)));
result.add(subList);
}
return result;
}
3.
改为: 入参为List<List<String>>
WHERE name IS NOT NULL
<if test="userids!=null and userids.size()>0" >
and
<foreach collection="userids" item="userid" open="(" separator="or" close=")">
createby in
<foreach collection="userid" item="createby" open="(" separator="," close=")">
#{createby}
</foreach>
</foreach>
</if>
效果 where xxx and (createby in (1,2,3,4,5 .... ,999) or createby in(1000,1001,....,1040))
最新文章
- Block formatting context(块级格式化上下文)
- Java生成随机验证码
- kaungbin_DP S (POJ 3666) Making the Grade
- bzoj 3718
- python 基础 基本数据类型
- 绘制图形与3D增强技巧(一)----点图元
- 【转载】Linux 与 BSD 有什么不同?
- C#新开一个线程取到数据,如何更新到主线程UI上面
- Oracle10g新特性——正则表达式 - 转
- wMy_Python ~储存相关~
- Unity3D 之3D动画机设置
- iOS ReactiveCocoa(RAC)学习详解
- Windows 10 安装 Docker for Windows
- 初识Java——一维数组的创建及使用
- Java Api Consumer 连接启用Kerberos认证的Kafka
- vue知识总结
- Redis的数据结构、通用操作及其特性
- OpenGL.Tutorial文章转载
- Oracle之ora-01031 insufficient privileges
- 大数据入门到精通2--spark rdd 获得数据的三种方法