我尝试在我的应用上删除SQLite数据库中的行 此代码为“Where field value equal”
mydatabase.delete("potentials", "stage=?", new String[]{"Ready for Install"});
但我需要“Where field value not equal”
mydatabase.delete("potentials", "stage!=?", new String[]{"Ready for Install"});
和
mydatabase.delete("potentials", "stage<>?", new String[]{"Ready for Install"});
我尝试了这段代码,但它不起作用
答案 0 :(得分:3)
你应该在比较器中使用不等运算符:&#34; stage!=?&#34;或&#34;阶段&lt;&gt;?&#34;。
mydatabase.delete(&#34; potential&#34;,&#34; stage&lt;&gt;?&#34;,new String [] {&#34; Ready for Install&#34;});
答案 1 :(得分:1)
尝试此功能:
public void DeletePostbyId(int id) {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("DELETE FROM " + TABLE_CHECK + " WHERE " + ID + "!='" + id + "'");
db.close();
//db.delete(TABLE_CAT, CAT_ID + "= ?", new String[]{String.valueOf(catid)});
}
答案 2 :(得分:0)
您的查询没有任何问题。它可能在这里失败的原因是字母案例......试试这个
mydatabase.delete("potentials", "upper(stage) != ?", new String[]{"READY FOR INSTALL"});
另请注意upper(stage)
附近的间距