I have one group table with a recursive relation, so each record has a parent_id. Given a group, I need to get all the student (each belong to a group) names in all its subgroups, but ordered by student name.
Do you know if there is any “easy” way to do it? If I have to do multiple queries, then I should order the results of the different Cursors, but Cursor has no orderBy().
Any ideas? Thank you so much!
As SQLite does not support recursive queries I implemented the select with two steps:
First, I have a method called
getRecursiveDiningGroupIdsAsString()that retreives all the group ids recursively whose parent id is the one you pass by parameter. The result is a String in the form of: “(2, 3, 4)” so you can later use it in anINclause. The method looks like:Once I have the group ids I need, I just do a simple query using the ids returned by the previous method and that is it!
Hope it helps!