开发者

Recursive summation between 2 tables in mysql

开发者 https://www.devze.com 2023-02-15 17:57 出处:网络
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:

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?!?!?

0

精彩评论

暂无评论...
验证码 换一张
取 消