Updated on 2024-07-19 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;