0

I have table like this:

+--------+---------+
| Id     | Pid     |
+--------+---------+
|      1 |       0 |
|      2 |       1 |
|      3 |       2 |
|      4 |       3 |
|      5 |       3 |
|      6 |       2 |
+--------+---------+

I want to select all parents id of a record and concat them like this:

+--------+---------+
| 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    |
+--------+---------+
gianglaodai
  • 301
  • 1
  • 10

0 Answers0