CodePudding user response:
Please list table structure and test data, we don't know if the statisticsCodePudding user response:
What all have no, don't know how to count, please post data and table structureCodePudding user response:
Write a recursive search stored proceduresCodePudding user response:
Set a field list, show several layers, if a person is 2, he showed 3 and so onCodePudding user response:
The original tree traversal time consuming, please check the preamble of the data structure, in sequence, after the sequence traversal,Tree structure can be out of shape, such as the grade of membership number, primary members a01 and secondary member a01b01 a01b01c01 level 3 members and so on...
Statistical referral number:
SELECT COUNT (1)
The FROM member_table
WHERE member_id LIKE 'a01 %'
See a few members,
The SELECT LENGTH (member_id)/3 AS member_level
The FROM member_table
(BTW now graded member "apparently suspected of national laws and regulations, the elder brothers be careful!)