开发者社区> 问答> 正文

sql查询数组越界问题。

代码:

if(type==1){
            String sql1 = "SELECT sum(c.couponfee/100) as'已省' FROM couponpublish c,couponpool e WHERE c.pubid=e.pubid AND e.status = 4 ";    
            List<Map> s = super.findListbySqlReturnMap(sql1);
            if(!s.isEmpty()){
                for(int i=0;i<s.size();i++){
                    list.add(s.get(i));
                }
            }
          int q = s.size();
          String sql ="SELECT e.content,e.logo FROM hh_coupon_equivalent e  WHERE  e.min<'"+s.get(q).get("sum(c.couponfee/100)")+"' AND e.max>'"+s.get(q).get("sum(c.couponfee/100)")+"'";
          List<Map> l = super.findListbySqlReturnMap(sql);
            if(!l.isEmpty()){
                for(int i=0;i<l.size();i++){
                    list.add(l.get(i));
                }
            }

先通过sql1查到sum(c.couponfee/100),放到s里,然后作为sql的查询条件查询e.min<'"+s.get(q).get("sum(c.couponfee/100)")报java.lang.IndexOutOfBoundsException: Index: 1, Size: 1数组越界吧。。应该怎么写呀

展开
收起
a123456678 2016-07-04 15:38:12 3640 0
1 条回答
写回答
取消 提交回答
  • s.get(q-1)
    
    s=[0,1]
    
    s.szie 是2
    
    s[2] 肯定越界了,只有 s[0] s[1]
    2019-07-17 19:50:44
    赞同 展开评论 打赏
问答分类:
SQL
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
SQL Server在电子商务中的应用与实践 立即下载
GeoMesa on Spark SQL 立即下载
原生SQL on Hadoop引擎- Apache HAWQ 2.x最新技术解密malili 立即下载