如何在 Android SQLite 查询中编写 where in 子句?
检索单个客户的功能
public Cursor getCustomers(int groupId) {
return db.query(TABLE_CUSTOMERS, new String[] { KEY_CUSTOMER_ID, KEY_NAME}, KEY_GROUP_ID+" = "+groupId, null, null, null, null);
}
检索更多客户的功能
public Cursor getCustomers(ArrayList<Integer> groupIds) {
// Need to apply SELECT id, name FROM customers WHERE id IN (11, 13, ...18);
//return db.query(TABLE_CUSTOMERS, new String[] { KEY_CUSTOMER_ID, KEY_NAME}, KEY_GROUP_ID+" = "+groupIds, null, null, null, null);
}
groupId ArrayList 的大小是动态的。