Ask php about mysql database layout

Source: Internet
Author: User
Ask php about the mysql database layout. There are two people in each of the following groups: one person in the left and right areas, and then infinitely extend. How can each member count the total number of members in the left and right zones?


Reply to discussion (solution)

This is a typical tree, binary tree, and algorithm. Recursion can be used to achieve

This is a typical tree, binary tree, and algorithm. Recursion can be used to achieve

Help write a data structure and computing code. thank you!



Amount of the superior ID
Id sh1 jine
1001 999 49
1002 1001 20
1003 1001 29
1004 1002 10
1005 1003 12
1006 1002 10
1007 1006 4
1008 1003 17
1013 1008 8
1015 1006 6
1021 1008
......

1001 how can I get the sum of the amounts with IDs 1002/1002/1004/1006/1007 in the left Zone 1015?

How do I get the sum of 1003/1005/1008 in the right zone and below?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.