I have a simple table in DB2 with the following structure:
ID | Description | ParentID
01 | Cat | 101
02 | Salmon | 201
03 | Dog | 101
101 | Mammals | 301
201 | Fish | 201
301 | Vertebrates | 401
401 | Animals |
This describes a hierarchical structure from the leaf records (in this case dog and cat) all the way up to animals.
How could I get all the descriptions for a given ID up to the topmost description (the one not getting any parentID in it)? for example, for ID 01, I would like to get: "Cat Mammals Vertebrates Animals"