Jump to content

[SOLVED] User Ranking


DEVILofDARKNESS

Recommended Posts

Okay so I want to make a ranking page for my game, in which people can see how they score against other players...

 

I have the following tables:

nations: nation_id, nation_name

regions: region_id, region_name, nation_id

 

The id's are primary keys, and auto_increment,

So I want that the nation with the most  regions is given:

 

example:

Nation_Name  Regions

DEVIL                5

DARKNESS        2

 

But I really have NO idea how I should begin on this one,

so please can someone give me a hint.

Link to comment
Share on other sites

Well this gives me:

nation_name region_count

Belgium        6

Belgium        6

Belgium        6

Belgium        6

Belgium        18

Belgium        126

 

There are more nations then Belgium and There are only 28 regions

 

 

BUT this doesn't matter,

because thanks to you code I saw an other way to solv'it (you couldn't know becuase you hadn't enough info)

the next one:

SELECT `nation_id` , COUNT( `region_id` ) AS `regions_count` 
FROM `regions` 
GROUP BY `regions`.`nation_id` 
ORDER BY `regions_count` DESC

 

And now I'm able todo a second query which is something like:

SELECT 'nation_name' FROM nations WHERE nation_id='$nationid';

 

Thanks a lot!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.