MySQL Forums
Forum List  »  Knowledge Base

Re: Count Hierarchical Data(Binary Tree) in MySQL?
Posted by: Manivel P
Date: January 29, 2010 02:56AM

The Child Nodes count is coming as 0.

this query is not helping..

Any advise on this.

SELECT parent.id, Count(distinct child.id) - 1 AS 'Child Nodes'
FROM sb parent
JOIN sb child ON child.left_id BETWEEN parent.left_id AND parent.right_id
GROUP BY parent.id;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Count Hierarchical Data(Binary Tree) in MySQL?
2356
January 29, 2010 02:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.