Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite delete one single row

I have a SQLite table defined this way:

CREATE TABLE Points(value INTEGER, player INTEGER, match INTEGER)

In the execution, I may have several identical columns, and I want a call which only deletes one, not all of them nor keeping just one. Is there any SQL call to do that?

An example to explain myself clearer:

value player match
1     2      3
1     3      3
1     2      3
2     2      3
1     2      3
1     2      3
1     3      3

db.delete("Points", "value = 1, player = 2, match = 3", null); //pseudo-code for the deletion
db.delete("Points", "value = 1, player = 3, match = 3", null);

value player match
1     2      3
2     2      3
1     2      3
1     2      3
1     3      3

I think db.delete("Points", "value = 1, player = 3, match = 3", null); will delete ALL columns which match the where clauses, am I right?

like image 386
user1897262 Avatar asked Jul 19 '26 10:07

user1897262


1 Answers

The delete statement you wrote will indeed delete all matching rows. Try to use the built-in column ROWID, read the first line, save the rowid, and then delete where ROWID= the value you selected.

like image 174
yoah Avatar answered Jul 22 '26 00:07

yoah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!