6

I would like to know if it is possible and how I could do a where clause in ActiveAndroid with a "IN" clause.

For example, I would like do do something like this:

new Select().from(Table).where("id in ?", list).execute()

Bruno da Hora
  • 61
  • 1
  • 3

3 Answers3

13

The query should work almost as is - ActiveAndroid reduces your SELECT to SQL anyway.

For example, the following LIKE query works for me:

public static List<Record> search(String searchTerm) {
    return new Select().from(Record.class)
            .where("Data LIKE ?", new String[]{'%' + searchTerm + '%'})
            .orderBy("Name ASC")
            .execute();
}

where search term is '%searchTerm%'

If you are having difficulty, you can query the DB directly, ie:

    mRecordList = SQLiteUtils.rawQuery(Record.class,
            "SELECT * from Records where Data LIKE ?",
            new String[]{'%' + searchTerm + '%'});
            */
rob123
  • 493
  • 1
  • 4
  • 14
1

new Select().from(Table).where("id in (1,2)").execute()

mg in dg
  • 11
  • 2
0

use this link for IN clause in activeandroid. Its bit difficult but check the answer given by jlhonora. it worked for me

https://github.com/pardom/ActiveAndroid/issues/392

vikoo
  • 2,451
  • 20
  • 27