android中不支持旧版本的SQL查询

时间:2013-04-09 08:32:21

标签: android android-sqlite

我已经在下面提到了这个问题。

这个查询目的在保存的本地数据库中的两列我发送了它的金额。对于那个将收取运费的金额。但旧版本的第一个值只能得到它。但是新版本成功更新。为什么我不知道它不是更新旧版本。

查询:

mCursor = db.rawQuery("select ROUND(deliverycharge) from pincodedetails where ROUND(subtotal) <=( select ROUND(subtotal)  from pincodedetails where ROUND(subtotal)>="+price+" and resturantID="+selArgs+" LIMIT 1) and resturantID="+selArgs+" and ROUND(subtotal) >=( select ROUND(subtotal) from pincodedetails where ROUND(subtotal)<="+price+" and resturantID="+selArgs+" LIMIT 1)  order by ROUND(subtotal) LIMIT 1", null);

我认为旧版本不支持 LIMIT 1

请给我解决方案吗?

public double getAllPincodeDetails(
            String dinein_restaurant_id,Double GetAllPrice ) {
        // TODO Auto-generated method stub
        String selArgs = dinein_restaurant_id;
        Double price = GetAllPrice;
        String query = "select ROUND(delivarycharge) from pincodedetails where ROUND(subtotal) <=( select ROUND(subtotal)  from pincodedetails where ROUND(subtotal)>="+price+" and resturantID="+selArgs+" LIMIT 1) and resturantID="+selArgs+" and ROUND(subtotal) >=( select ROUND(subtotal) from pincodedetails where ROUND(subtotal)<="+price+" and resturantID="+selArgs+" LIMIT 1)  order by ROUND(subtotal) LIMIT 1";
        Log.i(this.toString(), "Message"+query);
        mCursor = db.rawQuery("select ROUND(delivarycharge) from pincodedetails where ROUND(subtotal) <=( select ROUND(subtotal)  from pincodedetails where ROUND(subtotal)>="+price+" and resturantID="+selArgs+" LIMIT 1) and resturantID="+selArgs+" and ROUND(subtotal) >=( select ROUND(subtotal) from pincodedetails where ROUND(subtotal)<="+price+" and resturantID="+selArgs+" LIMIT 1)  order by ROUND(subtotal) LIMIT 1", null);
        double delivarycharge = 0;
        if (mCursor.moveToFirst()) 
        {
            // Got first result
            delivarycharge = mCursor.getDouble(0);
         //System.out.println("***************"+mCursor.getString(mCursor.getColumnIndex("totamount")));System.out.println("***************"+mCursor.getString(mCursor.getColumnIndex("price")));
        }
//
        return delivarycharge;
    }

1 个答案:

答案 0 :(得分:0)

SQlite只是一个有限的SQL实现......它的设计目的不同于大型DBMS。

您需要简化SELECT查询并在Java代码中执行一些处理。

见这里:SQL Lite Documentation