开发者

Dealing with WHERE IN(?) in Android SQLite raw query

开发者 https://www.devze.com 2023-01-28 23:25 出处:网络
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 ? selec

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号