-- Используя WHERE NOT EXISTS
SELECT *
FROM QEEN
WHERE NOT EXISTS (
SELECT ID FROM QEEN REVERSE_QEEN WHERE REVERSE_QEEN.A = QEEN.B AND REVERSE_QEEN.B = QEEN.A
);
-- Используя LEFT JOIN
SELECT QEEN.*
FROM QEEN
LEFT JOIN QEEN REVERSE_QEEN ON REVERSE_QEEN.A = QEEN.B AND REVERSE_QEEN.B = QEEN.A
WHERE REVERSE_QEEN.ID IS NULL;
-- Просто извращение, но тоже должно работать :)
WITH ALL_QEEN AS (
SELECT ID, A, B, 1 T FROM QEEN
UNION ALL
SELECT ID, B, A, 2 T FROM QEEN
) SELECT
MIN(ID) ID, A, B
FROM ALL_QEEN
GROUP BY A, B
HAVING COUNT(*) = 1 AND MIN(T) = 1;
Test SQL queries online