The table has two fields, id and pid. pid points to the id of the parent node and the pid value of the following node is 0
How to query and find all child nodes of an id node?
There are many ways.
The first method:
Read out all the elements from the database at once.
select * from table_name
Then let the program use references to construct mostly arrays.
The second method:
Recursive to the database to query. Find out a part at a time.
The third method:
Use database tables to link queries. Constantly join with oneself to obtain data.
The fourth method:
Redesign your database. Change to another model.
Before asking questions. GOOGLE the question first. There is an answer below. It is very detailed and exactly the same as the landlord’s question. .