Search code examples
mysqlparent-childhierarchydepth

Calculate depth in a parent-child model in MySQL


How do I calculate a node's depth in a parent-child model under MySQL?

I'll need the depth to, among other things, create the indent in my list (coded with PHP).


Solution

  • This might be an old question, but I just want to let others know that I found a solution some months ago. I did recently write about it here: http://en.someotherdeveloper.com/articles/adjacency-list-model-with-depth-calculation/