国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

mysql - sql How to query the third-level subset based on the parent id?
PHPz
PHPz 2017-05-18 10:51:03
0
2
1060

Now there is a need to query the third-level subset based on fid
A database table has three fields (id, name, fid)
id name fid
1 01 0
2 02 1
3 03 2
4 04 3
5 05 3
6 06 4
7 07 6
.............

Now how to query the content of the next three levels based on id
For example, if you check the lower three-level subset with id=3, the result is as follows. Is it best to display the level level?
id name fid (level)
4 04 3 1
5 05 3 1
6 06 4 2
7 07 6 3
How do you write this kind of SQL

PHPz
PHPz

學(xué)習(xí)是最好的投資!

reply all(2)
僅有的幸福

Let’s query it recursively

phpcn_u1582

Add a field level to the table and load all the data into the memory. Calculate the level and make corrections to the database. All future queries will be much easier.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template