I'm working with a tree structure in MySQL that is respresented using the nested sets model.
I'm hoping some of you sql experts can help me with building a SELECT query.
I would like to be able to match a set of nodes using LIKE. For each node that is matched, I also need a comma-delimmited list of the ancestors of that node, and a comma-delimmited list of the immediate children of that node.
I'm not really sure where to start with this - if such a thing is even possible in a single query. (Currently I am accomplishing this with a query inside a loop.) What I'm hoping for is a result set 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 looping queries would be much appreciated.