i have a table like this :
id | node_source | node_destination | path
1 | 1 | 0 | {"coordinates": [[-6.27400693507...
2 | 0 | 1 | {"coordinates": [[-6.24568104953...
3 | 1 | 2 | {"coordinates": [[-6.24568104953...
4 | 2 | 1 | {"coordinates": [[-6.27230059993...
i want to compare values of node_source and node_destionation between row 1 and row 2, row 3 and row 4.
if node_source in row 1 == node_destination in row 2 AND node_destination in row 1 == node_source in row 2 THEN display only first row (id=1)
if node_source in row 3 == node_destination in row 4 AND node_destination in row 3 == node_source in row 4 THEN display only third row (id=3)
The final output like this :
id | node_source | node_destination | path
1 | 1 | 0 | {"coordinates": [[-6.27400693507...
3 | 1 | 2 | {"coordinates": [[-6.24568104953...
Here my code (but not works) :
SELECT * FROM graph t1
WHERE NOT EXISTS(SELECT * FROM graph t2
WHERE t2.node_source = t1.node_destination AND t2.node_destination = t1.node_source
)
Help. Thanks.