Symmetric Pairs

  • + 0 comments

    ` select distinct results.XX, results.YY from ( select F1.ID1, F2.ID2, F1.X as XX, F1.Y as YY, F2.X, F2.Y from (select @rownum1 := @rownum1 + 1 as ID1, F.X, F.Y from (SELECT @rownum1 := 0) as r, Functions as F) as F1, (select @rownum2 := @rownum2 + 1 as ID2, F.X, F.Y from (SELECT @rownum2 := 0) as r, Functions as F) as F2 where F1.ID1 != F2.ID2 and F1.X = F2.Y and F1.Y = F2.X ) as results where results.XX <= results.YY order by results.XX;

    `