「followed」はフォローされているユーザーのID、「follower」は次のことを行ったユーザーのIDである「friends」というテーブルがあります。次のように設定します。
id | followed | follower
------------------------------
1 | 34 | 67
2 | 89 | 65
3 | 67 | 34
4 | 51 | 12
5 | 78 | 18
6 | 18 | 78
ユーザーが誰をフォローしているかを表示するクエリと、誰がユーザーをフォローしているかについてのクエリを簡単に実行できますが、私ができるようにしたいのは、友情がどこで往復しているかを示す単一のクエリを実行することです。
SELETCT * FROM friends WHERE
-- follower and followed have followed each other
したがって、上記の場合、これは ID 1 と 5 (または 3 と 6) を返します。
単一のクエリでこのマッチングを実現するにはどうすればよいですか?