I work with a tree structure in MySQL that is represented using a nested set model.
I hope some of you sql experts can help me create a SELECT query.
I would like to be able to map a set of nodes using LIKE. For each associated node, I also need a comma list of the ancestors of this node and a comma list for the immediate children of this node.
Iโm not sure where to start if this is possible even in one request. (I am currently doing this with a query inside a loop.) What I hope for is a set of results that might look something like this.
Starting with the string "qu" and querying the table "Body", I get ...
Node | Parent Nodes | Immediate Children Quads Leg, Lower Body, Muslces Vastus Lateralus, Vastus Medialis, Rectus Femoris Obliques Core, Trunk, Muscles Inner obliques, outer obliques
Any suggestions on how to accomplish this without loops would be greatly appreciated.
sql mysql hierarchical-data tree nested-sets
Travis
source share