Reputation: 139
SELECT `player`.`cid`, `player`.`k`, `player`.`d`, `gg`.`gg_id`, `gg`.`name`, `gg`.`img`, `cc`.`cid`, `cc`.`name`, `cc`.`class`, `cc`.`gg_id`
FROM `player`
LEFT JOIN `cc` ON `cc`.`cid` = `player`.`cid`
LEFT JOIN `gg` ON `gg`.`gg_id` = `cc`.`gg_id`
ORDER BY (`k`-`d`) DESC
i want to order by the K minus the D values, but im not getting it correctly what im a doing wrong? with or without DESC/ASC, its wrong
Upvotes: 2
Views: 930
Reputation: 7002
Try:
SELECT (
player
.k
-player
.d
), player
.cid
, player
.k
, player
.d
, gg
.gg_id
, gg
.name
, gg
.img
, cc
.cid
, cc
.name
, cc
.class
, cc
.gg_id
FROM player
LEFT JOIN cc
ON cc
.cid
= player
.cid
LEFT JOIN gg
ON gg
.gg_id
= cc
.gg_id
ORDER BY (player
.k
-player
.d
) DESC
I did a quick query of my own and the results appear to be unordered (despite the fact the were) until I added the SELECT (
. MySQL also complained about ommiting the table name in the player
.k
-player
.d
)ORDER BY
clause.
Upvotes: 1