Sqlite更新操作可以添加现有值吗?

时间:2019-04-20 22:39:44

标签: java android database algorithm sqlite

"UPDATE " + DatabaseFıelds.TABLE_NAME + 
" SET " + DatabaseFıelds.SUBJECT_PROGRESS + " = " + 
point + " WHERE " + DatabaseFıelds.SUBJECT_ID + " = " + id; 

此查询更新了我的值,但我希望它添加到现有值中。我该如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

我猜您想将point的值添加到DatabaseFıelds.SUBJECT_PROGRESS的现有值中,对吗?您可以这样做:

"UPDATE " + DatabaseFıelds.TABLE_NAME + 
" SET " + DatabaseFıelds.SUBJECT_PROGRESS + " = "  + 
DatabaseFıelds.SUBJECT_PROGRESS + " + " + point + 
" WHERE " + DatabaseFıelds.SUBJECT_ID + " = " + id;

答案 1 :(得分:0)

正在工作,谢谢forpas "UPDATE " + DatabaseFıelds.TABLE_NAME + " SET " + DatabaseFıelds.SUBJECT_PROGRESS + " = " + DatabaseFıelds.SUBJECT_PROGRESS + " + " + point + " WHERE " + DatabaseFıelds.SUBJECT_ID + " = " + id;