Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.