yongyitian 发表于 2013-10-29 12:47 
sorry, missing a THEN after id1=id3.
It was add.
No, your code is OK.
I was just saying the solution may not be unique based on Imasasor's description. The solution you get will depend on the order of data.
For example, your code returns (1,2) when the order is
but it yields (1,2), (2,3) if the order is
Another example, given a path like (1,2), (2,3), (3,4). If you delete (2,3) first, you'll end up with two records; or if you erase (3,4) first, you'll still get a chance to delete (2,3) and return only 1 record. Both solutions are correct but they are different.
I'm just not sure in which order one should break a loop, a cycle, or a path.
Imasasor has to define a complete set of rules for others to work on a program.