0

I am trying to update my table, But It gives me error how can I use AND operator in Where clause for update?

here is my code;

public static void updateData(long lday, String id, String usedamount, String trashedamount) {
        // TODO Auto-generated method stub
        ContentValues updatedValues = new ContentValues();          

        updatedValues.put("usedamount", usedamount);
        updatedValues.put("trashedamount",trashedamount);

        // HERE I WANT TO USE AND OPERATOR FOR DAY AND ID
        // this and operator gives error


        db.update("info_table", updatedValues, DAY + "=" + lday AND ID + "=" + id, null);

    }

Can anyone help me?

5
  • it does not update this code db.update("info_table", updatedValues, DAY + "=" + lday AND ID + "=" + id, null); Commented Mar 6, 2015 at 9:59
  • is it a compiler error? Commented Mar 6, 2015 at 10:00
  • Edit your question and add the exact error message you receive. Commented Mar 6, 2015 at 10:00
  • i mean what exception you are getting here? share the exception Commented Mar 6, 2015 at 10:00
  • it says Multiple markers at this line - The primitive type long of lday does not have a field ID Commented Mar 6, 2015 at 10:00

1 Answer 1

0

Your AND operator needs to be in quotation marks

public static void updateData(long lday, String id, String usedamount, String trashedamount) {
    ContentValues updatedValues = new ContentValues();          
    updatedValues.put("usedamount", usedamount);
    updatedValues.put("trashedamount",trashedamount);

    db.update("info_table", updatedValues, DAY + "=" + lday + " AND " + ID + "=" + id, null);
}
Sign up to request clarification or add additional context in comments.

1 Comment

yes it is fine but it needs 9 minutes to accept the answer :) thanks a lot.

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.