MySql tree depth

Discussion in 'MySQL' started by nihcer, Jul 13, 2008.

  1. #1
    Hi!

    I have a tree data structure inside 1 mysql table. Every record has defined a column parent_id, which obviously 'points' to the parent node and this satisfied the hierarchical needs to build the tree. What I'm missing here is the record depth(level) inside the tree - also, the tree can have N levels. It think this is possible to calculate with a recursive subquery (hope I'm not writing stupidities), but I don't know how. Any, ideas?

    Thanks!
     
    nihcer, Jul 13, 2008 IP