0

How could I find which number result a specific row is in a table?

For example, a table with names and ratings (ratings do not stay constant),

| name  |  rating  |
+-------+----------|
|  me   +     14   |
+-------+----------|
|  you  +    15    |
+-------+----------|

The query can only select one row at a time, so I'd like to incorporate this into it.

select name,rating,?????? from table where name = 'you' ORDER BY rating

how can i return 'you','15','2'?

i get the feeling i'm missing something very simple here...

d-_-b
  • 19,976
  • 37
  • 134
  • 224

1 Answers1

0

This would be ok:

SELECT @i:=@i+1 AS iterator, t.name, t.rating
FROM table t,(SELECT @i:=0) foo
johnnaras
  • 139
  • 10