I am trying to delete a row from a table but i have three WHERE clauses and i am not sure if i am using the correct statement.
db.delete(DBAdapter.TableName, "Id="+ Id
+" AND WHERE QstnrId = "+Integer.parseInt(QuestionnaireId)
+" AND WHERE QstnId = "+Integer.parseInt(QuestionId), null);
I am almost certain i am not using the statement correctly. Please assist?
The SQLite DELETE statement allows you to delete one row, multiple rows, and all rows in a table. The syntax of the SQLite DELETE statement is as follows: First, specify the name of the table which you want to remove rows after the DELETE FROM keywords.
The SQLite DELETE statement allows you to delete one row, multiple rows, and all rows in a table. The syntax of the SQLite DELETE statement is as follows: DELETE FROM table WHERE search_condition; In this syntax: First, specify the name of the table which you want to remove rows after the DELETE FROM keywords.
As we have to delete data from our SQLite database. For that, we have to create a method to delete our data from the SQLite database. Navigate to the app > java > your app’s package name > DBHandler and add the below code to it. Below is the updated code for the DBHandler.java file after adding the above code snippet.
If you compile SQLite with the SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option, you can use the ORDER BY and LIMIT clause in the DELETE statement like the following form: The ORDER BY clause sorts the rows filtered by the preceding search_condition in the WHERE clause and the LIMIT clause specifies the number of rows that to be deleted.
You don't need to use the WHERE
keyword. Also you could try using the third parameter to delete()
:
db.delete(DBAdapter.TableName, "Id=? AND QstnrId=? AND QstnId=?",
new String[] { Id.toString(), QuestionnaireId, QuestionId });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With