hello all!
i'm new here, and consider new also to mysql database.
i want to ask about mysql query, been 2 days thinking about it :mad:
here i got 1 table
CREATE TABLE x_world (
id int(9) unsigned NOT NULL default '0',
x smallint(3) NOT NULL default '0',
y smallint(3) NOT NULL default '0',
tid tinyint(1) unsigned NOT NULL default '0',
vid int(9) unsigned NOT NULL default '0',
village varchar(20) NOT NULL default '',
uid int(9) NOT NULL default '0',
people varchar(20) NOT NULL default '',
aid int(9) unsigned NOT NULL default '0',
alliance varchar(8) NOT NULL default '',
population smallint(5) unsigned NOT NULL default '0',
UNIQUE KEY id (id)
);
INSERT INTO world VALUES (1595,393,399,1,160524,'new town',3391,'bikz',0,'',19);
INSERT INTO world VALUES (3201,397,397,3,140157,'dangeroustown',1400,'up2u',0,'',347);
what i want to ask is how to count 10 biggest alliance in the world ? as you see on the table i dont have many choice there.
what came to my idea is count the total population in each alliance then we could find it, is it true ?
here what i got for that
$handle = mysql_query("SELECT SUM(DISTINCT population) AS atotalpop FROM world WHERE alliance='$allianceNAME'");
$row = mysql_fetch_assoc( $handle );
$atotalpop = $row['atotalpop'];
echo $atotalpop;
but i dont know how to count all alliance in the world table without using $allianceNAME
any expert here want to teach and share about the idea, i would be very happy.
i'm sorry for my bad english, thank you!