Search code examples
mysqltreenested-sets

get only direct child of node in nested set model


I read this http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ and in nested set model I want retrieve from parent node"portable electronics" only direct child "mp3 players" "cd players" "2 ways radios". How can I do?


Solution

  • It's described in the document you linked under the heading Find the Immediate Subordinates of a Node. As you can see it's pretty complex. When I use nested sets I always add a parent field as well, because that makes getting the direct children of a node a lot easier.