Count Hierarchical Data(Binary Tree) in MySQL?
Posted by:
Manivel P
Date: January 27, 2010 04:38AM
Hi,
I have questing on counting leaf nodes of binary tree.
My tables looks like below.
+------+---------+----------+
| ID | LEFT_ID | RIGHT_ID |
+------+---------+----------+
| 1 | 2 | 3 |
| 2 | 4 | 5 |
| 3 | 6 | 7 |
| 4 | 8 | 9 |
| 5 | NULL | NULL |
| 6 | 10 | 11 |
| 7 | 12 | 13 |
| 10 | 14 | 15 |
| 11 | NULL | NULL |
| 12 | NULL | NULL |
| 13 | NULL | NULL |
| 14 | NULL | NULL |
| 15 | NULL | NULL |
| 8 | NULL | NULL |
| 9 | NULL | NULL |
+------+---------+----------+
using this data i want count total leaf's.
For example count of leaf is 14 for 1, 4 for 2, 8 for 3, etc..
If anybody have thoughts to get this count in mysql db.
thanks,
-Mani
Subject
Views
Written By
Posted
Count Hierarchical Data(Binary Tree) in MySQL?
4580
January 27, 2010 04:38AM
2906
January 27, 2010 10:19AM
2483
January 29, 2010 02:56AM
Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
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.