Recursive summation between 2 tables in mysql
I have 2 tables: 开发者_如何学Pythonone of hierarchies:
X X/Y X/Z X/Z/A W/R W/Q W/R/D W/R/E ....and one of leaves: X/Z/A/3
X/Z/A/4 X/Z/2 X/Z/6 X/Y/A/8 X/Y/A/9 W/R/E/1 W/R/E/2 ....I Also have a table that connects every leaf/hierarchy, to its father:
X/Z/A/3 X/Z/A X/Z/A/4 X/Z/A X/Z/A X/Z W/R/E/1 W/R/E .....now, for every HIERARCHY, I need to sum up the number of leaves, recursively. Meaning, for example, that X/Z/A will have 2, and X will have 6
Any ideas?!?!?
精彩评论