• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[SQL query] Need help ^^

Kavvson

Gdy boli cie glowa wez
Joined
Jun 25, 2008
Messages
1,177
Reaction score
72
Location
Poland
PHP:
$guildMembers = $SQL->query( 'SELECT COUNT(`gr`.`id`) AS `total` FROM `players` AS `p` LEFT JOIN `guild_ranks` AS `gr` ON `gr`.`id` = `p`.`rank_id` WHERE `gr`.`guild_id` = '.$guild_id )->fetch( );

PHP:
$allM = $SQL->query ('SELECT COUNT(1) as `people` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') AND online = 1')->fetch();

How to convert this scripts into a 1. Top guild members count 2. Top guild members online...

As a site in gesior. ?subtopic=guildstats . Just like top fraggers script~~
 
PHP:
$guildMembers = $SQL->query( 'SELECT (SELECT COUNT(`gr`.`id`) FROM `players` AS `p` LEFT JOIN `guild_ranks` AS `gr` ON `gr`.`id` = `p`.`rank_id` WHERE `gr`.`guild_id` = '.$guild_id.') as `total`, (SELECT COUNT(1) FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') AND online = 1) as `people`' )->fetch( );

Like that? :p
 
I dont really need the '.$guild_id.' since it should show like top 5 guilds where is the most amount of members / members online
 
This should help you:
Select * From Guilds order by ownerid DESC LIMIT 5;

that is the same as in T-SQL:
Select TOP(5) * FROM Guilds order by ownerid
 
Back
Top