【发布时间】:2019-10-16 19:07:38
【问题描述】:
我有一个有两列的表。此表中的每一行都是图中的边:
v | w
-------
a a
a b
a c
b d
b b
c c
e f
g e
h h
我需要收集所有连接在一起的边:
result
-------
a,b,c,d
e,f,g
h
最好的方法是什么?创建一个游标并在表上循环并将所有边收集到临时表?或者可能有一些功能可以让这个任务更方便?
更新:
create table tt (
v text,
w text
);
insert into tt values('a', 'a');
insert into tt values('a', 'b');
insert into tt values('a', 'c');
insert into tt values('d', 'd');
insert into tt values('b', 'b');
insert into tt values('c', 'c');
insert into tt values('e', 'f');
insert into tt values('g', 'e') ;
insert into tt values('h', 'h') ;
【问题讨论】:
-
边的起点是什么?
v = w? -
@a_horse_with_no_name 没有起点。它是无向图。
标签: postgresql