Could someone help me get the following SQL statement working?
SELECT
standardgame.ga mename,
standardgame.ro wteamname,
standardgame.co lteamname,
standardgame.do llarvalue,
standardgame.ga meid,
standardgame.cu toffdatetime,
standardgame.ga metype,
standardgame.ga meowner,
(100-COUNT(purchased squares.gameid) ) AS squaresremainin g
FROM standardgame
LEFT OUTER JOIN
purchasedsquare s ON standardgame.ga meid = purchasedsquare s.gameid
where gametype='$game type' and dollarvalue = '$dollarvalue' and
gameowner = '
GROUP BY standardgame.ga meid
order by
CASE squaresremainin g WHEN 0 THEN 1 ELSE 0 END ASC,
squaresremainin g ASC
The problem is... MySQL doesn't seem to want to let me use
squaresremainin g in that case statement since it's not an official
column name. Any idea how I can reference squaresremainin g in the case
statement?
SELECT
standardgame.ga mename,
standardgame.ro wteamname,
standardgame.co lteamname,
standardgame.do llarvalue,
standardgame.ga meid,
standardgame.cu toffdatetime,
standardgame.ga metype,
standardgame.ga meowner,
(100-COUNT(purchased squares.gameid) ) AS squaresremainin g
FROM standardgame
LEFT OUTER JOIN
purchasedsquare s ON standardgame.ga meid = purchasedsquare s.gameid
where gametype='$game type' and dollarvalue = '$dollarvalue' and
gameowner = '
GROUP BY standardgame.ga meid
order by
CASE squaresremainin g WHEN 0 THEN 1 ELSE 0 END ASC,
squaresremainin g ASC
The problem is... MySQL doesn't seem to want to let me use
squaresremainin g in that case statement since it's not an official
column name. Any idea how I can reference squaresremainin g in the case
statement?
Comment