Skip to content

Instantly share code, notes, and snippets.

@jgdoncel
Created October 2, 2013 13:44
Show Gist options
  • Save jgdoncel/6794009 to your computer and use it in GitHub Desktop.
Save jgdoncel/6794009 to your computer and use it in GitHub Desktop.
Numerar filas en una consulta
# La siguiente consulta añade un campo numerado a una consulta:
set @num=0;
select id, @num:=@num+1 AS contando FROM tabla;
# Actualizar un campo
set @num = 0;
update tabla SET campo=(SELECT @num:=@num+1) where id_grupo=10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment