我想写一个Query来从表中删除一行。我很困惑写这个陈述。写这篇文章我需要一些帮助。我在这里用简单的sql语句提供我的要求。
(伪代码)
delete from tablename where value =="string1" && value2 == "string2" && value3 == "string3";
我想用android db.delete(tablename, whereclause, whereargs);
的Sqlite语法编写它。
我很感谢你的帮助。
答案 0 :(得分:28)
更好的方法是使用
String where = "value1 = ?"
+ " AND value2 = ?"
+ " AND value3 = ?";
String[] whereArgs = {string1,string2,string3};
答案 1 :(得分:16)
String table_name = "myTable";
String where = "value1 = 'string1'"
+ " AND value2 = 'string2'"
+ " AND value3 = 'string3'";
String whereArgs = null;
mDb.delete(table_name, where, whereArgs);
答案 2 :(得分:2)
mdb.delete("tablename",new String("value1=? and Value2=? and value3=?"),new String[]{value1,value2,value3});
答案 3 :(得分:1)
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("DELETE FROM tablename WHERE value1='"+string1+"' AND value2='"+string2+"' AND value3='"+string3+"' "); //delete row in a table with the condition
db.close();