Multiple value for single column in SQLite WHERE IN clause

DWQA QuestionsCategory: android questionMultiple value for single column in SQLite WHERE IN clause
kamal bunkar Staff asked 3 months ago

How to use SQLite where in clause? I have a column name as Status – where the value can be –

1) pending     2) approve     3) complete   4) delivered

Now I want all the row where the status value is complete OR delivered.

So how can I pass multiple value for single column in SQLite Where In clause?

1 Answers
kamal bunkar Staff answered 3 months ago

You have to use SQLite WHERE In clause not just WHERE clause. Write your code that way –
SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery("SELECT body FROM table1 WHERE title IN ('title1', 'title2', 'title3')", null);