[Android] SQLite IN 运算符在 Room 中的用法
假设 SQL 为:
SELECT * FROM nfc WHERE site_id IN (1,2);
错误用法:
@Query("SELECT * FROM nfc WHERE site_id IN (:siteIDs)")
fun getAllBySites(
siteIDs: String = "1,2"
): List<Nfc>
正确用法:
@Query("SELECT * FROM nfc WHERE site_id IN (:siteIDs)")
fun getAllBySites(
siteIDs: List<String> = listOf(1,2)
): List<Nfc>
或
@Query("SELECT * FROM nfc WHERE site_id IN (:siteIDs)")
fun getAllBySites(
siteIDs: Array<String> = arrayOf(1,2)
): List<Nfc>