表 - 朋友
friend_id | friend_one | friend_two | role
+--------------------------------------------------------------------------------------------+
|1: 44 34 34 me
|2: 45 35 35 me
|3: 46 35 34 fri
+--------------------------------------------------------------------------------------------+
我需要数数,谁在追随谁以及谁是追随者..这就是它,我在下面得到了一些答案,但大多只是给我静态数字但是感谢你到目前为止的帮助,它给了我一个地方开始。 FRIEND_ONE = 34(在表中用户34 =他们的uid对于35来说是相同的,依此类推)
之前我得到了这个答案,但它只是不断地为这两个中的一个返回0或3。
select friend_one, count(*) as count
from friends
where friend_one != friend_two
group by friend_one;
if you want the count for a specific user, do this:
select count(*) as count
from friends
where friend_one != friend_two
and friend_one = $uid