lundi 19 octobre 2015

Tree select sqlite

I am using sqlite in android and need to make an select to get all parent with their child's, for example:

id || parent_id || child_id || name

1     1            1           jhon
2     1            2           helen
3     2            3           barack
4     1            4           manuel
5     3            5           gaga

result should be:

jhon
helen
manuel
barack
gaga

So, I need a reqursive sql, but googling a bit I found that CTE is not supported on sqlite, anyway I can use even an recursive java method to return a list of selected names order by parent asc

Notice that tree depth can be more than 2 levels!

Aucun commentaire:

Enregistrer un commentaire