【发布时间】:2014-08-05 01:07:14
【问题描述】:
场景:
Person(pid:int,
name:char(20),
predecessor:int -> Person.pid
)
示例表:
pid, name, predecessor
0, 'abc', NULL
1, 'bcd', 0
2, 'cde', 1
3, 'efg', NULL
4, 'fgh', 3
如何找到 Person 'abc' 的所有后继者?
期望的输出:
name
'bcd'
'cde'
非常感谢!
【问题讨论】:
-
请编辑问题,提供示例数据和所需结果。
-
查看手册。它有这样的例子:postgresql.org/docs/9.3/static/queries-with.html
标签: sql postgresql recursive-query