PDA

View Full Version : Need a query to find the number of Friends members have


Mobo
09-04-2010, 05:55 AM
Hello all,

I am trying to find a query I can run that will output the number of Friends/Buddies members on my site have. Can someone please help with this?

Thanks,

Keith

Boofo
09-04-2010, 06:46 AM
Where are you wanting this to show up?

Mobo
09-07-2010, 10:57 AM
I just need to run it in the ACP to find the members with X number of Friends.

kh99
09-08-2010, 12:55 PM
There's a field called "friendcount' in the user table, so maybe

SELECT friendcount FROM vb_user WHERE userid=100


although I haven't tried it. Of course "vb_" should be whatever your table prefix actually is, and "100" should be the id of the user you're insterested in.

Mobo
09-11-2010, 04:34 AM
Thanks kh99, that did tell me the number of Friends for the use entered, but what I'm looking for is a query that will output the usernames of members that X number of Friends or more. Sorry, I should have been more clear on my needs.

sulasno
09-11-2010, 05:42 AM
not sure whether this would work

select friendcount,username,userid from vb_user;

Mobo
09-11-2010, 05:57 AM
That did work, any way to sort the results from most to least Friends? Right now randomly displayed across 64 pages.

ForumsMods
09-11-2010, 06:27 AM
Use this:

SELECT username, friendcount FROM vb_user WHERE friendcount >= 100

Replace vb with your table prefix and change 100.

Mobo
09-11-2010, 06:31 AM
The query sulasno posted worked, I added ORDER BY friendcount DESC to it to get it to sort the output by username with the most Friends first.

Thanks for everyone's help.

--------------- Added 1284190422 at 1284190422 ---------------

vB Style, yours worked as well allowing me to set the cutoff number for Friends.

kh99
09-11-2010, 01:10 PM
Thanks kh99, that did tell me the number of Friends for the use entered, but what I'm looking for is a query that will output the usernames of members that X number of Friends or more. Sorry, I should have been more clear on my needs.

I should have realized that you'd want to output more than the number, I just wasn't thinking.