从表中删除行时遇到问题。这应该很简单,但我不明白为什么不起作用。这是我的表格创建:
database.execSQL(
"CREATE TABLE " +PERSONAL_LIST_EXERCISES_TABLE +" (" +
PERSONAL_LIST_ID +" INT, " +
EXERCISE_ID +" INT);");
我试图使用以下查询删除行:
db.rawQuery(
"DELETE FROM " +PERSONAL_LIST_EXERCISES_TABLE +
" WHERE " +EXERCISE_ID +" LIKE '" +String.valueOf(exerciseId) +"'" +
" AND " +PERSONAL_LIST_ID +" LIKE '" +String.valueOf(listId) +"'", null);
我还尝试使用delete方法:
db.delete(
PERSONAL_LIST_EXERCISES_TABLE, EXERCISE_ID +" =? AND " +PERSONAL_LIST_ID +" =? ",
new String[] {String.valueOf(exerciseId), String.valueOf(listId) });
两者都不起作用。有什么想法吗?
最佳答案
我看不出错误,试试这个:
db.rawQuery("DELETE FROM " + PERSONAL_LIST_EXERCISES_TABLE +
" WHERE " + EXERCISE_ID + " LIKE " + String.valueOf(exerciseId) +
" AND " + PERSONAL_LIST_ID + " LIKE " + String.valueOf(listId) , null);
或者这个
db.delete(
PERSONAL_LIST_EXERCISES_TABLE, EXERCISE_ID +" = ? AND " +PERSONAL_LIST_ID +" = ? ",
new String[] {String.valueOf(exerciseId), String.valueOf(listId) });
我所做的唯一更改是放置空格并退出(')
也试着把“%”字符放在类似的句子上