Oracle in 的個數超過1000
阿新 • • 發佈:2021-01-30
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 (.......................) )