Wykster Posted November 30, 2007 Share Posted November 30, 2007 Hi, Please bear with me as I am learning this stuff. I have a query that gives me the top 5 players of a dart team by their maximum average. When I run it, I get the top 5 averages but they are all distinct players names. I know for a fact that in the top 5 averages the same player is in positions 1, 2, and 3. Here is the query that I have built, I aplogise but could somebody advise me on how to change the query to give me the top 5 regardless of the same player appearing in the top 5. $max_average_mb_sql = mysql_query("SELECT MAX(match_records.ave) AS mbave, players.playerID, players.playerName, players.surname FROM match_records, players WHERE match_records.playerID = players.playerID AND match_records.seasonID = $season_seasonid AND match_records.MorF = 'M' AND match_records.AorB = 'B' AND match_records.W_L = 'W' GROUP BY players.playerName, players.surname ORDER BY mbave DESC LIMIT 0 , 5"); Regards Dave Quote Link to comment Share on other sites More sharing options...
fenway Posted December 2, 2007 Share Posted December 2, 2007 If that's the case -- and you want top 5 unique players -- you'll have to write an inner query to select the players (why are you grouping by name and not by uid?), and then join it back to the count query. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.