Questo dovrebbe funzionare
update
content,
(
select
@row_number:=ifnull(@row_number, 0)+1 as new_position,
ContentID
from content
where CategoryID=1
order by position
) as table_position
set position=table_position.new_position
where table_position.ContentID=content.ContentID;
Ma preferirei applicarlo prima, per annullare l'impostazione della variabile definita dall'utente
set @row_number:=0;
Aggiunto da Mchl:
Puoi farlo in una dichiarazione come questa
update
content,
(
select
@row_number:=ifnull(@row_number, 0)+1 as new_position,
ContentID
from content
where CategoryID=1
order by position
) as table_position,
(
select @row_number:=0
) as rowNumberInit
set position=table_position.new_position
where table_position.ContentID=content.ContentID;