A喜欢B,但B不喜欢A?

Boo*_*bie 1 sql postgresql

如果我的表名为Table,看起来像这样:

A B
1 2
3 2
2 1
etc...
Run Code Online (Sandbox Code Playgroud)

这意味着1喜欢2,3喜欢2,2喜欢1 ...假设它比这要大很多,我怎么写一个SQL查询,我报告哪里A喜欢B,但B不喜欢A?

因此,对于这种情况,示例输出应该是:

3 2
Run Code Online (Sandbox Code Playgroud)

因为3从关系中喜欢2,但是2不喜欢3.

Mar*_*tos 6

SELECT A, B
  FROM likes x
 WHERE NOT EXISTS (SELECT * FROM likes
                    WHERE x.A = B AND x.B = A)
Run Code Online (Sandbox Code Playgroud)