我有一张桌子
scores(user, score)
我有这个查询
SET @row_num = 0;
SELECT @row_num := @row_num + 1 as row_index, user, score
FROM scores ORDER BY score DESC
现在我想从这个查询结果中选择名称为“john”且得分为“1400”的用户,以了解他的 row_index 是什么,类似于
SELECT row_index
FROM *result* WHERE user='john' AND score=1400
我怎么做?我试过
SET @row_num = 0;
SELECT row_index
FROM (SELECT @row_num := @row_num + 1 as row_index, user, score
FROM scores ORDER BY score DESC)
WHERE user='john' AND score=1400`
但 phpMyAdmin 说
#1248 - Every derived table must have its own alias
我怎样才能做到这一点?
谢谢你,亚历山德罗