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
递归查询出来吧
表增加个字段level,数据全部load到内存里,计算下level做下数据库的订正,以后各种查询就容易多了。