Get the paths from a database of points in sql
Consider that I have a table of points, each point has 2 coordinates. For example: Source | Destination 1 | 2 2 | 3 3 | 7 5 | 7 9 | 12 I'd like to write a query in SQL that gives me the following: All the paths that these points make. Each path must have connected points, as in the next point's source coordinate is the same as the previous point's destination point. a path can't be cyclic. For example, in the table above, running the query should return 3*paths: (1,2) (2,3) (3,7) (5,7) (9,12) I thought about duplicating the points table, let's call them A and B, then set a condition: SELECT