ActiveAndroid, where with the condition "in"

I would like to know if this is possible, and how I can make a where clause in ActiveAndroid with a "IN" clause.

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

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

+5
source share
3 answers

The query should work in much the same way as - ActiveAndroid still shortens your SELECT to SQL.

For example, the following LIKE request 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 the search query is "% searchTerm%"

If you are having difficulty, you can directly query DB, that is:

  mRecordList = SQLiteUtils.rawQuery(Record.class, "SELECT * from Records where Data LIKE ?", new String[]{'%' + searchTerm + '%'}); */ 
+9
source

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

+1
source

use this link to suggest IN in activeandroid. Its a bit complicated, but check out the answer provided by jlhonora . it worked for me

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

0
source

Source: https://habr.com/ru/post/1213142/


All Articles