我有下表:
习惯
ID INT PRIMARY KEY
NUMBER INT FOREIGN KEY
DATE DATE
DONE BOOL
NUMBER INT PRIMARY KEY
NAME VARCHAR
DESCRIPTION VARCHAR
我要对HABIT中特定行进行更新,其中HABIT_DESCRIPTION的名称为
我尝试过:
ContentValues cv = new ContentValues();
cv.put(HABIT_COL_DONE, true);
String whereclause = HABIT_DESCRIPTION_NAME+ "='water'";
return db.update("HABIT",cv,whereclause,null);
答案 0 :(得分:0)
由于 SQLite 不支持UPDATE
语句中的联接,因此可以使用EXISTS
:
String whereclause =
"EXISTS (SELECT 1 FROM HABIT_DESCRIPTION WHERE NUMBER = HABIT.NUMBER AND DESCRIPTION = ?)";
String param = "water";
return db.update("HABIT", cv, whereclause, new String[] {param});