1. 程式人生 > 其它 >Oracle java.sql.SQLSyntaxErrorException: ORA-01795: 列表中的最大表達式數為 1000

Oracle java.sql.SQLSyntaxErrorException: ORA-01795: 列表中的最大表達式數為 1000

Oracle 語法 in 後集合 不能超過1000,

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