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 precompi开发者_如何学Cled 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.
No, you can't do that. You have to use ... WHERE table.column IN (?, ?, ?, ?)
and add the parameters separately.
精彩评论