我创建了一个如下表格:
ID Name Phone Address
-----------------------------
1 xyz 980 abc
2 sdf 382 sdff
3 hdj 322 abc
4 jks 346 abc
5 sdfd 344 abc
我想删除所有包含Address = "abc"
和Phone = {"980", "346", "322"}
如何在Android SQLite中完成上述查询?
答案 0 :(得分:2)
它应该足够吗?
db.rawQuery("DELETE FROM my_table WHERE column_address='abc'
AND column_phone IN ('980', '346', '322')");
如果您想通过删除方法执行此操作,那么我假设您可以通过以下方式执行此操作:
for(String phone : phoneNumbers){
db.delete("my_table", "column_address = ? AND column_phone = ?",
new String[]{"abc", phone});
}
答案 1 :(得分:1)
这会对你有所帮助
delete from Table where Address = 'abc' and (Phone = '980' or Phone = '980' or Phone = '322')