I need to run two statements like so:
Select amount from db where ID=5 DELETE from db where ID=5
Currently I prepare and run two different statements. I wonder if there is a way to combine it in one statement.
Basically all I need to do is to get an amount column from the row before it is deleted.
I used this: String[] Ids = new String[]{"1", "2", "3"}; mContext. getContentResolver(). delete(CONTENT_URI, ID + " IN (?, ?, ?)",Ids);
SQLite DELETE Query is used to delete the existing records from a table. You can use WHERE clause with DELETE query to delete the selected rows, otherwise all the records would be deleted.
select * from mytable where myvalue like 'findme%'; then replacing "select *" with "delete" should delete them. delete from mytable where myvalue like 'findme%'; That should work with any SQL database, as long as you have sufficient permissions.
SQLite does not support this extension to standard SQL -- you do have to use both statements, SELECT first, DELETE next. You can wrap them in a transaction, of course, (BEGIN and COMMIT statements before and after will guarantee that), to guarantee atomicity and consistency.
If you just want to select rows and delete them in one pass, you can use the returning clause in the delete statement.
For instance:
delete from myTable returning *
The delete statement has all select functionalities possible such as with
and where
that permits to select rows with any logic.
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