0

嗨,我已经在下面提到了这个查询。

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

询问:

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;
    }
4

1 回答 1

0

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

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

请参阅此处: SQL Lite 文档

于 2013-04-09T08:43:46.287 回答