Answers for "mysql update sequence with order by"

SQL
0

mysql update sequence with order by

SET @rank:=0;
update tablename
set fieldname =@rank:=@rank+1 ORDER BY fieldorder;

#OR

UPDATE tablename
JOIN (SELECT @rank := 0) r
SET fieldname=@rank:=@rank+1 ORDER BY fieldorder;
Posted by: Guest on March-24-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language