1. 程式人生 > 其它 >Oracle in 的個數超過1000

Oracle in 的個數超過1000

技術標籤:Oracleoraclesql

Oracle in 的個數超過1000

在這裡插入圖片描述
Oracle中在一個查詢語句裡 in 的個數最多為1000個
當我們in的個數有1000+時,可以考慮使用union all來查詢
把in的個數以一次999個來查詢用union all來連線起來,然後就可以了

select DJXH,NSRMC,nsrsbh,JK_BZ,ZT_DM from
(
select DJXH,NSRMC,nsrsbh,JK_BZ,ZT_DM from sxgl_fxts where jk_bz='Y' AND ZT_DM=83 and djxh in
(.......................)
union all
select DJXH,NSRMC,nsrsbh,JK_BZ,ZT_DM from sxgl_fxts where jk_bz='Y' AND ZT_DM=83 and djxh in
(.......................)
union all
select DJXH,NSRMC,nsrsbh,JK_BZ,ZT_DM from sxgl_fxts where jk_bz='Y' AND ZT_DM=83 and djxh in
(.......................)
union all
select DJXH,NSRMC,nsrsbh,JK_BZ,ZT_DM from sxgl_fxts where jk_bz='Y' AND ZT_DM=83 and djxh in
(.......................)
)