Destramic Posted July 25, 2010 Share Posted July 25, 2010 ive added SET @rank := 0; and @rank := @rank + 1 AS rank, to my query and it now comes back with errors because of this and i dont see why...can someone please explain why its not working MySQL Error #1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT @rank := @rank + 1 AS rank, t.team_id, ' at line 2. SET @rank := 0; SELECT @rank := @rank + 1 AS rank, t.team_id, t.team_name, COUNT(r.league_match_result_id ) AS 'matches_played', COUNT(CASE r.result WHEN 'Win' THEN '3' END) AS 'wins', COUNT(CASE r.result WHEN 'Loss' THEN '0' END) AS 'losses', COUNT(CASE r.result WHEN 'Draw' THEN '1' END) AS 'draws' FROM teams t LEFT JOIN league_match_results r ON r.team_id = t.team_id LEFT JOIN team_leagues tl ON tl.team_id = t.team_id LEFT JOIN league_matches m ON r.league_match_id = m.league_match_id WHERE tl.league_id = :1 GROUP BY t.team_id ORDER BY wins DESC, draws DESC, losses DESC Quote Link to comment https://forums.phpfreaks.com/topic/208839-mysql-statement-help/ Share on other sites More sharing options...
mrqpro Posted July 26, 2010 Share Posted July 26, 2010 Remove : like this set @rank = @rank + 1 Quote Link to comment https://forums.phpfreaks.com/topic/208839-mysql-statement-help/#findComment-1091215 Share on other sites More sharing options...
Mchl Posted July 26, 2010 Share Posted July 26, 2010 Are you trying to run both thhese queries at once using mysql_query Quote Link to comment https://forums.phpfreaks.com/topic/208839-mysql-statement-help/#findComment-1091236 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.