我在SQLite Android中有一张表
table name- score
columns- rank time moves
我想增加那些时间大于给定时间的记录的排名,所以我写了这两个代码。
ContentValues updatedValue = new ContentValues();
updatedValue.put(KEY_RANK, KEY_RANK+1); //KEY_RANK is a final string "rank" column name
db.update(SCORE, updatedValue, KEY_TIME_ELAPSED + ">=" + time, null); //KEY_TIME_ELAPSED = "time"
和其他片段是
db.rawQuery("UPDATE "+ TABLE_NAME2 + " SET "+ KEY_RANK + " = " + KEY_RANK + " + 1 WHERE " + KEY_TIME_ELAPSED + " >= " + time + ";", null);
在这两种情况下,它都没有更新。谁能说我哪里错了?在我的情况下,这两个片段都是正确的更新方式吗?如果一个或两个都错了,那么请指出哪一个是错的?