未超过 1000 时的写法:
- select *
- from tbl_temp
- where
- id in
- <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- select *
- from tbl_temp
- where
- id in (1,2,3)
超过 1000 时的写法:
- select *
- from tbl_temp
- where
- <foreach item="item" index="index" collection="ids" open="(" separator="or" close=")">
- id in #{item}
- </foreach>
- select *
- from tbl_temp
- where
- (id in 1 or id in 2 or id in 3)
参考博客:
mybatis 关于 oracle in 1000 个数限制的解决 - Paul Joo 的专栏 - CSDN 博客
来源: http://www.bubuko.com/infodetail-3045789.html