這是我的方法從那裏appointment_date等於在爲什麼這樣的DELETE查詢不起作用?
public void deleteAllAppointments(String date) {
SQLiteDatabase db = this.getWritableDatabase();
String deleteAllQuery = "DELETE FROM " + TABLE_APPOINTMENTS + " WHERE appointment_date = '" + date + "'";
db.rawQuery(deleteAllQuery, null);
Log.d("Query: ", deleteAllQuery);
}
過去的日期數據庫中刪除一行,然後我用它像這樣
//Database (DatabaseHandler is the one that contains all database methods)
final DatabaseHandler database = new DatabaseHandler(this);
//This happens when button is clicked, it is tested an executes with every chick,
//@param selectedDate is a string like "18/03/2014"
database.deleteAllAppointments(selectedDate);
它執行和查詢看起來像這
DELETE FROM appointments WHERE appointment_date = '18/03/2014'
然而與約會_日期='18/03/2014'的行不會被刪除。
我敢肯定數據庫設置正確,因爲我有它的工作方法,所有信息都以正確的格式從那裏接收。
注意:將「*」添加到「DELETE * FROM ...」將返回致命的語法錯誤。
發生與添加*的錯誤,因爲這是不恰當的SQL語法。要刪除整個表格,你只需說DELETE FROM TABLE_NAME,*僅用於選擇查詢 – Rarw