Reputation: 41
I want delivery charge compared to subtotal and calculate delivery charges. I got the result successfully. I get query and I put in that code execute in Execute SQL. I got correct answer. But
I have some problem in retrieve data. I got result everytime first position value only .
Below I have mention my code.Give me solution.
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";
Database Helper Class:
double deliverycharge= 0;
if (mCursor.moveToFirst()) {
// Got first result
deliverycharge= mCursor.getDouble(0);
}
return deliverycharge;
Upvotes: 0
Views: 91
Reputation: 18151
Try this
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";
You need the as "whatever name you want"
Upvotes: 0
Reputation:
You should change your code to retrieve to something like:
Vector<String> temp = new Vector<String>;
cursor.moveToFirst();
do {
deliverycharge= mCursor.getDouble(0);
temp.add()
} while (cursor.moveToNext());
return temp;
So you will return a vetor containing all Strings.
Upvotes: 1