1

i'm new to nested set model and trying to find the first available node in a tree starting from top to bottom and left to right. each parent node can have 3 child node and i have to find the next available free node.

Table mem fields m_id,lft,rgt so far i'm only able to find the depth. like i said i'm new don't know the path ahead

SELECT node.m_id,node.lft,node.rgt, (COUNT(parent.m_id) - 1) AS depth

FROM mem AS node, mem AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt GROUP BY node.m_id ORDER BY depth,node.lft;

0 Answers0