Sqlite Delete Query syntax in Android

后端 未结 4 1364
不知归路
不知归路 2021-01-04 21:37

I want to write a Query to delete a row from the table. I am confused of writing the statement. I need some help in writing this. I am providing my requirement here with pla

相关标签:
4条回答
  • 2021-01-04 22:01

    a better way would be to use

    String where = "value1 = ?"
    + " AND value2 = ?"
    + " AND value3 = ?";
    String[] whereArgs = {string1,string2,string3};
    
    0 讨论(0)
  • 2021-01-04 22:01
    String table_name = "myTable";
    String where = "value1 = 'string1'"
        + " AND value2 = 'string2'"
        + " AND value3 = 'string3'";
    String whereArgs = null;
    mDb.delete(table_name, where, whereArgs);
    
    0 讨论(0)
  • 2021-01-04 22:01
    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();
    
    0 讨论(0)
  • 2021-01-04 22:02
    mdb.delete("tablename",new String("value1=? and Value2=? and value3=?"),new String[]{value1,value2,value3});
    
    0 讨论(0)
提交回复
热议问题