Help with reordering rows (MySQL)
#1

Hey there, I was wondering if there was any way we could reorder rows with MySQL? For example, let's say I want to make a /toptime command, and for example if someone is in the first position and someone overtakes his position he moves on to the second position, then the person in the second position moves on to the third, etc. Any suggestions? Thanks.
Reply
#2

Like this?
pawn Код:
SELECT `username`,`score` FROM `players` ORDER BY `score` ASC LIMIT 10
Selects and orders top 10 players by score asc (1, 2, 3 etc).

EDIT: Found a useful tutorial on the SQL Side of it here. Click next page, and it will teach you all you need to know.
Reply
#3

Not really, I already know how to get the TOP players, I just want to know how to change their positions, for example I have this table:
Код:
Position        Username         Time
    1             Name            10
    2             Name            22
    3             Name            30
    4             Name            44
    5             Name            51
And if someone gets a time of lower than 10 seconds, he moves on the the first position, the person who WAS in the first position moves on the the second, and so on..
Reply
#4

Nevermind, I figured it out on my own, lock.
Reply
#5

Quote:
Originally Posted by m1kas
Посмотреть сообщение
Nevermind, I figured it out on my own, lock.
post the solution so others can see how to solve this kind of problem.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)