Working with WHERE IN (?) In SQLite SQL Query

How to work with raw queries in an Android database containing many arguments? For example, SELECT * FROM table WHERE table.column IN (15, 14, 17, 19) . Can I use precompiled SQL with a selection ? , or is there no other choice but to format each request separately with concatenation?

I do

  SQLiteDatabase.rawQuery ("... WHERE table.column IN (?)", SelectionArgs); 

where selectionArgs is a String concatenated identifiers, but the request will not be executed.

+6
android sqlite
source share
1 answer

No, you cannot do this. You should use ... WHERE table.column IN (?, ?, ?, ?) And add the parameters separately.

+5
source share

All Articles