Is it possible to query a tree structure table in MySQL in a single query, to any depth?

Yes, this is possible, it’s a called a Modified Preorder Tree Traversal, as best described here

Joe Celko’s Trees and Hierarchies in SQL for Smarties

A working example (in PHP) is provided here

http://www.sitepoint.com/article/hierarchical-data-database/2/

Leave a Comment