Рассмотрим следующее ...
DROP TABLE IF EXISTS my_table;
CREATE TABLE my_table
(id SERIAL PRIMARY KEY
,user1 INT NOT NULL
,user2 INT NOT NULL
);
INSERT INTO my_table (user1,user2) VALUES
(1, 2),
(2, 1),
(1, 3),
(4, 1);
SELECT x.*
FROM my_table x
JOIN
( SELECT MIN(id) id
FROM my_table
GROUP
BY LEAST(user1,user2)
, GREATEST(user1,user2)
) y
ON y.id = x.id;
+----+-------+-------+
| id | user1 | user2 |
+----+-------+-------+
| 1 | 1 | 2 |
| 3 | 1 | 3 |
| 4 | 4 | 1 |
+----+-------+-------+