gpt4 book ai didi

sql - 如何在 postgresql 中使用行的父级?

转载 作者:搜寻专家 更新时间:2023-10-30 19:50:44 25 4
gpt4 key购买 nike

我的表有两列:scopename 及其parent name
https://www.dropbox.com/s/qsajdyzs5hwt6zg/table.jpeg?dl=0

enter image description here


我想要树来轻松获取应用程序中的数据。就像这些

https://www.dropbox.com/s/48da6vg694estg8/table2.jpeg?dl=0

enter image description here


我该怎么做?请帮我 !我无法更改数据库或表的结构。
附言我使用 postgresql
P.S2.表的简单部分,scopename

可能有 4 个甚至 5 个父级

最佳答案

我想你想做一个递归连接。

举个例子: Postgresql recursive self join

这是 PostgreSQL 文档: http://www.postgresql.org/docs/current/static/queries-with.html

关于sql - 如何在 postgresql 中使用行的父级?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31700547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com