小编tuc*_*max的帖子

如何使用 PostgreSQL 更改层次结构树中的字符串输出?

我有一张这样的表:

-------------------------------------------------
|  id  | description         | parent_id   |  cost
--------------------------------------------------
| 1    |  Radiology         |       NULL  | 0.00
| 2    |  Lab Tests         |       NULL  | 0.00
| 3    |  Normal Radiology  |         1   | 0.00
| 4    |  Resonance         |         1   | 100.00
| 1100 |  Cerebral Resonance|         4   | 200.00
| 1900 |  Blood Tests       |         2   | 10.00
| 2044 |  Calcium           |         2   | 50.00

---------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

我需要生成这种输出:

Radiology
   -->Normal Radiology
   -->Resonance
      -->Cerebral Resonance with contrast …
Run Code Online (Sandbox Code Playgroud)

postgresql cte recursive string-manipulation

2
推荐指数
1
解决办法
158
查看次数

标签 统计

cte ×1

postgresql ×1

recursive ×1

string-manipulation ×1