Hi,
I have a big table (1M rows) with the following columns:
source, dest, distance.
Each row defines a link (from A to B).

I need to find the distances between a pair using anoter node.
An example:
If want to find the distance between A and B,
If I find a node x and have:
x -> A
x -> B
I can add these distances and have the distance beetween A and B.
My question:
How can I find all the nodes (such as x) and get their distances to (A and B)?
My purpose is to select the min value of distance.

P.s: A and B are just one connection (I need to do it for 100K connections).
Thanks !

You must mean from A to x and then from x to B. Otherwise, it doesn't make much sense. If we are talking at most one intermediate node, you can just join the table to itself, filtering for you start and end node, and doing an aggregate query. However, if you are talking about n-number of nodes where n is not known, your table structure does not support that type of query. You would have to redesign your table to include a tree data structure of some sort.

Thanks Rabbit.
There is no mistake with the directions:
For measuring A->B, I'm looking for the node (X) that gives a minimum value for dist(X->A) + dist(X->B).
I have several topologies I need to check (2 nodes...) but I first want to solve the basic one.
Can you help me with the query your suggested (using JOIN)?
Thanks

My point is that solving for the specific form is a waste of time if your end goal is to solve for the generic form. Yes, we can get a solution to solve for the 1-intermediary node problem, but the solution for n-intermediary node is completely different.

I'm not interested in a solution for n-intermediary node, but only in several topologies (for 1 and 2 intermediary nodes).
I want to try with a simple topology and derive the others respectively.
I'll be happy to get help with the query.
Thanks