bravo14 Posted March 31, 2017 Share Posted March 31, 2017 Hi I have a mysql query that generates a league table based on wins, losses and draws etc, but also points difference between how many they score and how many are scored against them. The query works except for the points difference part, the offending part of the query is shown below @F:=SUM(IF(tbl_clubs.club_id = tbl_fixtures.away,tbl_fixtures.awayscore,0)) + SUM(IF(tbl_clubs.club_id = tbl_fixtures.home,tbl_fixtures.homescore,0)) as `F`, @A:=SUM(IF(tbl_clubs.club_id = tbl_fixtures.home,tbl_fixtures.awayscore,0)) + SUM(IF(tbl_clubs.club_id = tbl_fixtures.away,tbl_fixtures.homescore,0)) as `A`, SUM(@F - @A) as `PtsDiff`, Using the code above I am getting NULL as a result even though there should be a figure calculated. Quote Link to comment https://forums.phpfreaks.com/topic/303584-query-not-calculting-using-declared-variables/ 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.