tags:

views:

35

answers:

1

how can we count total friend to specific uid

+2  A: 

COUNT is not supported by FQL:

SELECT uid2 
FROM friend 
WHERE uid1 = USERID

Since COUNT is not supported you need to get all of the records and then count them in whatever application that is making the SQL call.

If you want to get more information, like names, along with count you can use an inner select to get the friend's extended info:

SELECT name 
FROM user 
WHERE uid IN (SELECT uid2 
              FROM friend 
              WHERE uid1 = USERID)

Here is a related SO question:

FQL result count

References for Friend table:

Query this table to determine whether two users are linked together as friends.

Kelsey

related questions