Jump to content

query not calculting using declared variables


bravo14

Recommended Posts

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.

Link to comment
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.