Mysql: Update Table Field from 0 to N based on WHERE and ORDER BY
SET @rank:=0;
update yourTABLE 
set yourTABLE.field=@rank:=@rank+1
WHERE yourTABLE.id IN (3,1,2,5,10) ORDER BY FIELD(id,3,1,2,5,10)

Tags:

Comments are closed.