I need to get a progressive number next on each row out of my SELECT query.
i.e. Query result without numbering:
user_id
paola
Carla
Marta
what i want is
number user_id
1 paola
2 Carla
3 Marta
I am aware that the problem is very similar to the one in
MySQL - Get row number on select
And on the first query the code suggested in the answers seems to work for me too BUT when I recall the query, or when i try to export the results, i get a NULL value in the column where the row number is supposed to be.
Do you know why? Did I do something wrong in the variable instance?
The code I use is the following:
set @x=0;
SELECT @x:=@x + 1 AS row_index, user_id FROM TABLE ORDER BY user_id