Oracle java.sql.SQLSyntaxErrorException: ORA-01795: 列表中的最大表达式数为 1000

Oracle   语法  IN   后集合 不能超过1000, IN 的个数建议控制在 200 以内。

select  *  from   table   where  id in   (  '1' , '  ', '   ',.........,'1000')   

解决方式

1、分多次查询,最大不超过 1000, 然后将结果汇总

2、把参数分开 一次查询 

  select   *  from  table where id  in (   '1' , '  ', '   ',.........,'1000' )  or  id  in (   '1' , '  ', '   ',.........,'1000'  ) 

3、在 in 后接一个  查询语句

  select  *   from  table1  where   id  in  ( select id   from  table2)

4、使用 with  as 语法,把条件封装成一个表

with  tmp  as  (select  id  from  table1)

select  *  from  table2  where  id   in  (select  id from  tmp)    

  

 

参考:https://www.cnblogs.com/jhxxb/p/10830547.html

posted @ 2021-07-21 16:27  唏嘘-  阅读(1087)  评论(0编辑  收藏  举报