0

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;

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

10 Comments

i got only one result sunhari.No need list and all
If you need to retrieve all strings then how can you do without vector or list or String[]? @Gomathi
Because every time String will be overwritten @Gomathi
I don't need all string value just only one string For example 40 only
And how is that decided? I mean which String do you need? Is it always first column data? @Gomathi
|
0

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"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.