我有一列要减 1。下面的代码似乎不起作用。
ContentValues dataToUpdate = new ContentValues();
dataToUpdate .put(MARKER_ID, MARKER_ID+"-1");
String where = IMAGE_ID_F+" = " +imageId+ " AND "+MARKER_ID+" > "+markerId+";";
int resultUpdate = db.update(TABLE_DEFECTS, dataToUpdate, where, null);
我也试过了rawQuery
。那也没有用。
MARKER_ID是列的名称。
String restructureDbQuesry="UPDATE "+TABLE_DEFECTS+" SET "+MARKER_ID+" = "+MARKER_ID+"-1"+" WHERE "+IMAGE_ID_F+" = " +imageId+ " AND "+MARKER_ID+" > "+markerId;
Cursor resultUpdate = db.rawQuery(restructureDbQuesry,null);
迭代后的结果查询:
UPDATE defects SET Marker_Id = Marker_Id-1 WHERE Image_Id = 2 AND Marker_Id > 2