I have a tabel containing a column named parent which is able to store a parent ID.
This makes it possible to create a tree-structure of my data.
Are there any good helper-functions for travelling through such a tree-structure in MySQL?
For example, if I have a row in my table and I want to be able to retreive all “parents” above it. So getting the it’s parent’s parent ID and so on…
Copied from this popular link:
You can use this to find all parents from node
FLASH:Retrieving a Single Path
This works because the child’s
leftwill be in between its parents’leftandright.You can read further or search for modified preorder tree traversal.