简体   繁体   English

在Android的Sqlite中更新值和ContentValues

[英]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? 是否有某种方法可以在不创建原始查询的情况下(例如,使用update(String table, ContentValues values, String whereClause, String\\[\\] whereArgs)函数或其他使用ContentValues的类似方法)来抓住字符转义和该提供商的其他优势?

The query I want to achieve is something like: 我要实现的查询类似于:

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

The GREATEST function is actually called MAX : GREATEST函数实际上称为MAX

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM