I have a table with data pairs modeled like the following:
Id1 Id2
-----------
100 50
120 70
70 50
34 20
50 40
40 10
Id1
is always bigger then Id2
. The pairs represent replacements to be made. So 100 will be replaced with 50, but then 50 will be replaced with 40, which will then be replaced by 10.
So the result would be like this:
Id1 Id2
-----------
100 10
120 10
34 20
Is there a nice succinct way that I can alter, or join this table to represent this?
I know i can join it on itself something akin to:
SELECT t1.Id1, t2.Id2
FROM mytable t1
JOIN myTable t2 ON t2.Id1 = t1.Id2
But this will require several passes, hence why i ask if there is a nicer way to accomplish it?