Addev
Addev

Reputation: 32233

Updating values in Sqlite of Android and ContentValues

I want to update a row in a table, updating all the columns to new values except one that should keep the greatest value between the old and newValue.

Is there some way of doing this without creating the raw query (for example using the update(String table, ContentValues values, String whereClause, String\[\] whereArgs) function or other similar using ContentValues) in order to seize the character scaping and other advantages of that providers?

The query I want to achieve is something like:

UPDATE users SET name='newName', address='newAddress',
                 lastLogin=GREATEST(lastLogin,1348757941);

Upvotes: 0

Views: 576

Answers (1)

CL.
CL.

Reputation: 180080

The GREATEST function is actually called MAX:

UPDATE users
SET name = 'newName',
    address = 'newAddress',
    lastLogin = MAX(lastLogin, 1348757941)

Upvotes: 1

Related Questions