Question:
I want to make a sql query and I want each row to have a column indicating the row number ex:
linha nome
1 joao
2 maria
3 tiago
. .
. .
. .
n joares
But, this column "row" I don't have in the table, so I'm trying to do something like:
select count(nome), nome from pessoas;
The problem is that when I use count ()
Answer:
To avoid the declaration you can use the variable as a table:
select
@num := @num + 1,
u.usu_nome
from tab_usuario u, (SELECT @num := 0) as t
group by u.usu_id;