Here is some example data in a mysql table
a b distance 15 44 250 94 31 250 30 41 250 6 1 250 95 18 250 72 84 500 14 23 500 55 24 500 9
I wonder if this will work?
SELECT a,b,distance FROM YourTable t2 WHERE ROW(a,b,distance) IN ( SELECT a,b,distance FROM YourTable t1 WHERE t1.distance=t2.distance ORDER BY RAND() LIMIT 2 )
EDIT: unfortunately not. LIMIT is not supported in a subquery.