1
/ \
2 3
/ \ / \
4 5 6 7
/ \ \
8 9 11
/ \
10 12
/ \
13 14
Am having a binary tree like this. Here, 1 is the parent and I wanna count all the children in both left and right side of 1
And I am having the following mysql table structure
**id** **amount** **left** **right**
1 3000 2 3
2 3000 4 5
3 750 6 7
4 750 8 *null*
5 3000 *null* 9
6 750 *null* *null*
7 750 *null* 11
8 750 10 *null*
9 3000 *null* *null*
10 3000 13 14
11 750 *null* 12
12 3000 *null* *null*
13 750 *null* *null*
14 3000 *null* *null*
Now I wanna count all the left nodes as well as the right nodes based on the plan amount of the ID's Though am having thousands of data . Is it possible to count all the nodes by differentiating them by the plan amount? For Example if the ID 2 contains 5 IDs ( 4, 8, 10, 13, 14 ) in it's left side and each IDs are of different Plan amount can I count how many IDs under 2 are in 750 plan ?? using php