As you may know, in order to query values that match any values in a predefined list, you can use the IN
check.
For example:
SELECT *
FROM categories
WHERE id IN (1, 2, 3, 4)
It’s easy for raw SQL but how to achieve that using Sqflite
?
1
2
3
4
5
6
final ids = [1, 2, 3, 4]
db.query(
'categories',
where: "id IN (${ids.map((_) => '?').join(', ')})",
whereArgs: ids,
);
The main point is to generate enough ?
placeholders in your where
statement and you’re good to go!
Happy coding! đź’»