Updated on 2024-04-28 GMT+08:00

ORDER BY

In MySQL, if an UPDATE statement includes an ORDER BY clause, the rows will be updated in the order specified by the clause.

Input

1
2
# ORDER BY 
UPDATE employees SET department_id=department_id+1 ORDER BY id;

Output

1
2
-- ORDER BY 
UPDATE "public"."employees" SET "department_id" = department_id+1;