I have your run of the mill nested set hierarchy type setup with the following columns:
table name:
myset
columns:
id, name, lft, rgt
Does anyone know a query to determine the parent of a node?
I read a couple places that it’s handy to also have a parent_id column in your table to keep track of this, but it seems redundant and it seems like it could get out of sync with the nested set if a query was incorrectly executed when adding/removing/moving anything within the set.
Look at this question. It is similar to yours. I have posted there a query you may need.
I hope there is what you need.
For the following table:
it produces the output: