SET @rownum=0;
UPDATE [table] t, (SELECT @rownum:=@rownum+1 rownum, [table].* FROM [table]) r
SET t.[field] = r.rownum
WHERE (t.[primary_key] = r.[primary_key])
Update field with row_num in MYSQL
最新推荐文章于 2024-08-18 15:09:09 发布
SET @rownum=0;
UPDATE [table] t, (SELECT @rownum:=@rownum+1 rownum, [table].* FROM [table]) r
SET t.[field] = r.rownum
WHERE (t.[primary_key] = r.[primary_key])