I have a table
scores(user, score)
and I have this query
SET @row_num = 0;
SELECT @row_num := @row_num + 1 as row_index, user, score
FROM scores ORDER BY score DESC
now I want to select, from this query result, the user with name ‘john’ and score ‘1400’ to know what is his row_index, something like
SELECT row_index
FROM *result* WHERE user='john' AND score=1400
how do I do that? I tried
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`
but phpMyAdmin says
#1248 - Every derived table must have its own alias
How can I do that?
Thank you,
Alessandro
You haven’t added an alias to the derived table.