Jump to content

[MySQL/LUA]counting player with most records


kuwalda

Recommended Posts

So I have mysql table which holds basiclly 2 main values: playerName and recordMap.

Lets say I have 20 racing maps. If any player got time record on 11 maps, he is defined as "king", because noone can beat him(max map records for others is 9).

So I have 2 main questions:

* How can I count who is the "king"? Which player has the most map records? (mysql)

* How can I count it with LUA?

The main problem for me is that I understand SQL, but I can`t think of any resource efficient way of doing this.

Any help would be appriciated. :|

Link to comment

Wow, really? It's not hard at all xD

1. Add a value "topTimeCount" to every player row in the table

2. Make it so when a player beats a top time, that value is increased by 1

3. Make it so when a player loses his top time, the value is decreased by 1

4. Sort them by that value. You're done.

Link to comment
Wow, really? It's not hard at all xD

1. Add a value "topTimeCount" to every player row in the table

2. Make it so when a player beats a top time, that value is increased by 1

3. Make it so when a player loses his top time, the value is decreased by 1

4. Sort them by that value. You're done.

That's quite hard, because the times of a race is being saved as a new row ( top 5, if I'm right ). So he can just use the COUNT() function from SQL to actually get the numbers back. Just add the COUNT(*) in the where class, order it DESC and limit it to 0,1 so you only get the 'king'. Also add the group by for the map ( so you only get 1 value of every map ) and add a order by value for the time. ^^

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...