You can join your table to itself putting the equality between start and endnote as in the following example
select A.* from connections A
inner join connections B on (A.startnode=B.endnode and A.endnode = B.startnode)
Domanda
I have a tricky question and I couldn't really find an answer that would suit my database schema.
Let's say I have the following table:
CONNECTIONS
And the following columns
connID, StartNode, EndNode
and let's say you can have bi-directional connection from StartNode to EndNode
StartNode -> EndNode
EndNode -> StartNode
And it's represented in a table as the following:
CONNECTIONS
|connID | StartNode | EndNode |
| 1 | 9 | 10 |
| 2 | 10 | 9 |
| 3 | 9 | 11 |
My question is: What SQL statement would help me in retrieving all the connections that are bi-directional (and in this case the first 2 connections above with connId 1 and 2?
Soluzione
You can join your table to itself putting the equality between start and endnote as in the following example
select A.* from connections A
inner join connections B on (A.startnode=B.endnode and A.endnode = B.startnode)