Jump to content

mysql statement help


Destramic

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/208839-mysql-statement-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.