SELECT DISTINCT a.*
FROM TableName a
INNER JOIN TableName b
ON a.from = b.to
AND a.to = b.from
WHERE a.from < b.from
SELECT DISTINCT a.*
FROM TableName a
INNER JOIN TableName b
ON a.from = b.to
AND a.to = b.from
WHERE a.from < b.from