I need to write a select query for a network diagram. There are two tables;
select * from node;
num | node
-----+------
1 | a
2 | b
3 | c
4 | d
select * from edge;
e1 | e2
----+----
a | b
c | d
a | c
I need a select statement which would give me the edge values in the form of numbers like this;
1-2
3-4
1-3
I am using postgresql 8.4 but is should not have any relevance to my question.
Thank you.
A couple of JOINs should do the trick:
If you want the output as a string exactly as in your question then use this instead: