View Full Version : Need a query to find the number of Friends members have
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?
I just need to run it in the ACP to find the members with X number of Friends.
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.
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;
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.
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.
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.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.