我有这样的表:
+--------+---------+
| Id | Pid |
+--------+---------+
| 1 | 0 |
| 2 | 1 |
| 3 | 2 |
| 4 | 3 |
| 5 | 3 |
| 6 | 2 |
+--------+---------+
我想选择记录的所有父ID,并将它们连接起来:
+--------+---------+
| ID | pidList |
+--------+---------+
| | |
| 1 |0 |
| 2 |1,0 |
| 3 |2,1,0 |
| 4 |3,2,1,0 |
| 5 |3,2,1,0 |
| 6 |2,1,0 |
+--------+---------+