Reputation: 151
I have created a table like below:
ID Name Phone Address
-----------------------------
1 xyz 980 abc
2 sdf 382 sdff
3 hdj 322 abc
4 jks 346 abc
5 sdfd 344 abc
I want to delete all records which is having Address = "abc"
and Phone = {"980", "346", "322"}
How can I fulfill the above query in Android SQLite?
Upvotes: 0
Views: 217
Reputation: 68187
should it be enough?
db.rawQuery("DELETE FROM my_table WHERE column_address='abc'
AND column_phone IN ('980', '346', '322')");
in case you want to do it via delete method, then i assume you may do it by:
for(String phone : phoneNumbers){
db.delete("my_table", "column_address = ? AND column_phone = ?",
new String[]{"abc", phone});
}
Upvotes: 2
Reputation: 2452
this will help you
delete from Table where Address = 'abc' and (Phone = '980' or Phone = '980' or Phone = '322')
Upvotes: 1