MySQL查询,列出按点和排名排序的所有记录。但是现在,如何从名称中获取特殊列?
查询:
SET @a=0;
SELECT (@a:=@a+1) as Rank, `player`, `points`, `id` FROM `score`
ORDER BY `points` DESC (WHERE player='example');
感谢您的帮助。 :)
我正在使用Java。
答案 0 :(得分:0)
select * from
(
SELECT (@a:=@a+1) as Rank, `player`, `points`, `id`
FROM `score`
CROSS JOIN (select @a := 0) ta
ORDER BY `points` DESC
) tmp
WHERE player='example'
答案 1 :(得分:0)
在此WHERE
之前使用ORDER BY
子句 -
SET @a=0;
SELECT (@a:=@a+1) as Rank, `player`, `points`, `id` FROM `score`
WHERE player='example' ORDER BY `points` DESC;