隨筆 - 100  文章 - 50  trackbacks - 0
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          收藏夾

          我收藏的一些文章!

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          在Oracle中,sql中in不能超過1000個,比如:select  * from table  t where t.id in (1,2,3,......1001,1002)
          系統將報錯,解決辦法如下,寫成兩個或者多個。如:t.id in (1,2,....1000) or t.id in (1001,1002)
          實現代碼如下:
           public String DivString(){
            StringBuffer sb = new StringBuffer();
            StringBuffer sb2 = new StringBuffer();
            List agentList = new ArrayList();
            for(int i =0;i<1100;i++) 
             agentList.add(i);
            for(int i=0;i<agentList.size();i++){
             if(i==agentList.size()-1)
              sb.append("'").append(agentList.get(i)).append("')");
             else if(i%1000==0&&i>0)
              sb.append("'").append(agentList.get(i)).append("'")
              .append(") or t.id in (");
             else
              sb.append("'").append(agentList.get(i)).append("',");
            }
            sb2.append(" t.id  in ('',"+sb);
            System.out.println("sql is: "+sb2.toString());
            return sb2.toString();
           }
          posted on 2010-01-11 22:48 fly 閱讀(3326) 評論(2)  編輯  收藏 所屬分類: 數據庫學習

          FeedBack:
          # re: oracle sql in中數據不能超過1000個的解決方法。 2010-08-20 21:10 
          你這個方法都不行,不要抄了,以后  回復  更多評論
            
          # re: oracle sql in中數據不能超過1000個的解決方法。 2011-08-03 09:52 幽野閑鶴
          查多次不久完了,in效率那么低.查多次效率比in高多了
            回復  更多評論
            
          主站蜘蛛池模板: 海原县| 慈溪市| 察隅县| 永清县| 登封市| 年辖:市辖区| 元谋县| 遂昌县| 瑞丽市| 通州市| 菏泽市| 保山市| 绍兴市| 永吉县| 广昌县| 淮北市| 凤阳县| 涡阳县| 讷河市| 塔城市| 内丘县| 涿鹿县| 迭部县| 长垣县| 喀喇沁旗| 和田市| 怀集县| 新绛县| 平罗县| 潜江市| 秦皇岛市| 彩票| 阆中市| 九龙城区| 克山县| 龙川县| 肇庆市| 韩城市| 库车县| 阿拉尔市| 正蓝旗|