Got a question, just to save time and accelerate a request people have on one of my mods. How would I write a good SQL to pick out the top 3 scores per game assuming that the structure is id, gameid, score, personid. I got it to work on group by but I want the top 3 to be picked out in the result array for each game. The high scores table may have hundreds of scores for any of the games. Table is highscores and database type is MySQL.
If you want result each game you can add in: select * from game where gameid = id order by score not sure if can do all the games at once without group feature
I think we need some more details here. you need to select Top 3 gamers per game right? if so, then the top 3 highscored people from a specified game will be: $query = select * from highscores where gameid=1 order by score desc limit 3; //will return best 3 players for game 1. PHP: that will show the top 3 players of a game, starting with highest result.
Again... select from will be from highscores fields are primid, gameid,score,userid (not exact but pseudocode kind of speak) I know how to bring all the games up with no problem, such as the SQL you posted. What I get stuckon and did in my job all the time is complex SQL statements What you posted I could of done myself if I wanted. I am not interested in ONE game, but the top 3 scores for ALL the games. The SQL (and I know it's possible, just stuck) should call up only the top 3 high scores for each game. Now keep in mind that there might be 20 high scores recorded for a game, 1 the next, so on.