SQLite database update query with multiple where conditions in Android

Rohit picture Rohit · Sep 9, 2014 · Viewed 35.4k times · Source

I want to update my database table with multiple where conditions. I already did with single where condition

db.update(TABLE_MISSING_ITEMS, values, KEY_AUTHOR + " = ?",
                new String[] { String.valueOf(items.getAuthor()) }); 

Now i want 2 where condition.

P.S :- No raw query

Answer

Manas Bajaj picture Manas Bajaj · Sep 9, 2014

You can separate the different WHERE conditions with ANDlike this:

db.update(TABLE_NAME,
    contentValues,
    NAME + " = ? AND " + LASTNAME + " = ?",
    new String[]{"Manas", "Bajaj"});