Finding a users maximum score and the associated details

Posted by VolatileStorm on Stack Overflow See other posts from Stack Overflow or by VolatileStorm
Published on 2010-03-28T22:51:44Z Indexed on 2010/03/28 22:53 UTC
Read the original article Hit count: 207

Filed under:
|
|

I have a table in which users store scores and other information about said score (for example notes on score, or time taken etc). I want a mysql query that finds each users personal best score and it's associated notes and time etc.

What I have tried to use is something like this:

SELECT *, MAX(score) FROM table GROUP BY (user)

The problem with this is that whilst you can extra the users personal best from that query [MAX(score)], the returned notes and times etc are not associated with the maximum score, but a different score (specifically the one contained in *). Is there a way I can write a query that selects what I want? Or will I have to do it manually in PhP?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about grouping