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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with top N records using limit

Status
Not open for further replies.

jgurgen

Programmer
Mar 9, 2006
192
US
im trying to restrict my query to the first 5 record but its not working it keeps returning all records.

// Performing SQL query
$query = 'SELECT GameID, Date(GameDate) AS GameDate, G_Time, R_Name,
(SELECT Concat(Team.SchoolName,\' \',Team.Mascot) FROM Team WHERE Team.TeamID=A_TeamID) AS AwayTeam,
A_TeamScore,
(SELECT Concat(Team.SchoolName,\' \',Team.Mascot) FROM Team WHERE Team.TeamID=H_TeamID) AS HomeTeam,
H_TeamScore,
Game.ResultType
FROM Game
INNER JOIN Team ON A_TeamID=Team.SchoolName OR H_TeamID=Team.TeamID
INNER JOIN Rink ON Game.Rink_ID = Rink.Rink_ID
WHERE Game.DivisionID='.$did.' AND Game.Completed = 0 AND Game.SeasonID=2 AND Game.GameType=\'Regular\'
GROUP BY GameID
ORDER BY GameDate ASC, G_Time ASC
LIMIT 5';
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top