MySQL错误的ORDER BY

时间:2009-11-20 18:49:33

标签: mysql sql-order-by

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

我想按K减去D值排序,但我没有正确使用它 我做错了什么?有或没有DESC / ASC,错了

1 个答案:

答案 0 :(得分:1)

尝试:

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_idFROM 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

我快速查询了自己的内容,结果似乎是无序的(尽管事实如此),直到我添加了player。 MySQL还抱怨在k子句中省略了表名。