Reputation: 580
How to deal with raw queries in Android DB that contain a lot of arguments? For example SELECT * FROM table WHERE table.column IN (15, 14, 17, 19)
. Can I use precompiled SQL with ?
selections, or is there no other choice than to format each query individually with concatenation?
I'm doing
SQLiteDatabase.rawQuery("... WHERE table.column IN (?)", selectionArgs);
where selectionArgs
is String
of joined IDs, but the query won't execute.
Upvotes: 6
Views: 7660
Reputation: 838376
No, you can't do that. You have to use ... WHERE table.column IN (?, ?, ?, ?)
and add the parameters separately.
Upvotes: 5