你好,我想说一个例子
我的关注表
A B
1 2 // same so its friend
2 1 // same so its a friend
1 3 // user 1 is following 3
1 4 // user 1 is following 4
Run Code Online (Sandbox Code Playgroud)
等等
让我们说我们是用户1我们如何列出我们的朋友?我脑子里有点像
SELECT COUNT(*) FROM social WHERE ((A = B) = (B = A)) as friends
// so it will be something like count friends where ( 1 = 2 ) = ( 1 = 2) if you get my logic
Run Code Online (Sandbox Code Playgroud)
或者我们能以某种方式这样做吗?
如果它工作,它将计为1