android - Querying records and making them groups from SQLite Table -
i not understanding how can done in single query.
problem:
i have table
id| phonenumber| message| group_name| datetime
example data
1 | 987654321 | "hi" | g1 | xxxxxxx 2 | 987654321 | "hi" | g1 | xxxxxxx 1 | 987145678 | "hello" | g2 | xxxxxxx
what want query above sqllite table in such way need grab rows of particular phonenumber in descending order of datetime
. can put them in hashmap key group_name
, value arraylist of messages
.
hashmap<string, arraylist<string>> mapper = new hashmap<>();
i using greendao library fetch data sqllite, tried below
list<activity> activities = activitydao.querybuilder().where(new wherecondition.stringcondition(com.ficean.android.ficean.db.activitydao.properties.contact_number.eq(phonenumber) + "group group_name")).orderdesc(com.ficean.android.ficean.db.activitydao.properties.date_time).build().list();
i managed above query using group by
not listing rows.do have data of particular number , separate looping through each row based on group_name ? or there better way do?
the sql quite simple, where
clause , order by
.
the sql looks this:
select t.* t t.phone = ? order t.datetime desc;
i not sure how translates sql generator, involve removing group by
.
Comments
Post a Comment