Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAX() Aggregation Problem

Status
Not open for further replies.

Repton

Programmer
Aug 3, 2003
1
AU
I am trying to join three tables using the following query:

$query_SCORES = "SELECT
MAX(_hsSCORES.Totalscore) as Awin,
date_format(_hsSCORES.Date, '%d.%m.%Y') as SDate,
_hsSCORES.Featurewin,
_hsSCORES.Gameversion,
_hsUSERS.Nickname,
_hsUSERS.Country,
_Gameslist.Gamename,
_hsSCORES.Userlink,
_hsUSERS.Usernumber,
_hsUSERS.Email,
FROM _hsSCORES, _hsUSERS, _Gameslist
WHERE _hsSCORES.Userlink = _hsUSERS.Usernumber
AND _hsSCORES.Gametype = _Gameslist.Gametype
AND _hsSCORES.Subgametype = _Gameslist.Subgametype
GROUP BY _Gameslist.Creationnumber
ORDER BY _Gameslist.Gamename";

on MySQL version 3.2 (Host won't upgrade).

The query is designed to get the highest score for every type of game, and then get that users details.

The highest score in the _hsSCORES table is calculated properly, and the game name is retrieved properly from _Gameslist table for all games listed, but all of the other data is retrieved not for the highest score record in the _hsSCORES table, but for the lowest, in every single case (from _hsUSERS).

Is there a way to correctly perform this whole thing without running more than one query?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top