Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

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;
 
PREVIOUS NEXT
Tagged: #mysql #update #sequence #order
ADD COMMENT
Topic
Name
8+2 =