0

我想将运费与小计进行比较并计算运费。我成功地得到了结果。我得到查询,然后在 Execute SQL 中执行该代码。我得到了正确答案。但

我在检索数据时遇到了一些问题。我每次只得到第一个位置值的结果。

下面我提到了我的代码。给我解决方案。

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";

数据库助手类:

double deliverycharge= 0;
if (mCursor.moveToFirst()) {
    // Got first result
    deliverycharge= mCursor.getDouble(0);
}
return deliverycharge;
4

2 回答 2

1

您应该更改您的代码以检索到类似的内容:

Vector<String> temp = new Vector<String>;
cursor.moveToFirst();
do {

    deliverycharge= mCursor.getDouble(0);
    temp.add()                  
} while (cursor.moveToNext());
return temp;

因此,您将返回一个包含所有字符串的向量。

于 2013-03-19T07:15:20.207 回答
0

尝试这个

String Query ="select ROUND(delivarycharge) as roundcharge 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";  

你需要作为“你想要的任何名字”

于 2013-03-19T07:26:30.227 回答