说实例我有下表(成员之间充满了连接)
connectionA ConnectionB
887 225
129 887
225 887
887 562
562 887
如何使用SQL查找A连接到B的所有行,反之亦然。查询将返回(不允许重复):
connectionA ConnectionB
887 225
887 562
答案 0 :(得分:3)
SELECT T1.connectionA, T1.connectionB
FROM yourtable T1
JOIN yourtable T2
ON T1.connectionA = T2.connectionB
AND T2.connectionA = T1.connectionB
WHERE T1.connectionA > T1.connectionB