I have an existing (old) sqlite database structure that looks like this:
╔══════════╦═══════════╦══════════╗
║ id_group ║ id_parent ║ sequence ║
╠══════════╬═══════════╬══════════╣
║ 1 ║ 0 ║ 0 ║
║ 10 ║ 1 ║ 70 ║
║ 117 ║ 10 ║ 30 ║
║ 124 ║ 117 ║ 40 ║
║ 174 ║ 3998 ║ 60 ║
╚══════════╩═══════════╩══════════╝
Where id_parent
points to another id_group
to create hierarchy.
How can I create a query that will give me the whole hierarchy in one go? Of course, I could just go through all the id_parent
s and write down each level of the hierarchy, but that seems unnecessary and also tedious.
PS: If it's not possible with SQL alone, I can also utilize PHP, C#, Python and whathaveyou.