Reputation: 161
I have a database where it is possible for several rows to be identical. I want to have the ability to only delete the first of the identical rows. I tried using the LIMIT statement but I get an SQLiteException error when I try to use LIMIT. I've tried doing several google searches and I've come up with nothing. Can you not use LIMIT and delete on android? Below is my exact code. Thanks
db.execSQL("DELETE FROM "+table+" WHERE " + someColumn+"='"+somevalue+"' LIMIT 1")
Upvotes: 2
Views: 1900
Reputation: 2808
It may not enable for Android SQLite, since it's optional:http://www.sqlite.org/lang_delete.html
What you have to do is to SELECT all you want (assume you dont have ORDER BY). get the id of the first one, DELETE FROM table WHERE id="123456".
Hope its help.
Upvotes: 5