I have a query which works well in our PostgreSQL db, but we now need to run our app on a MySQL DB as well.
The query takes an array of IDs and positions, and updates each record with given ID with a new value for the respective position.
UPDATE items
SET position = i_vals.position
FROM (VALUES (1,12), (2, 13), (3,11)) AS i_vals(id, position)
WHERE i_vals.id = items.id;
How can I rewrite this query to be MySQL and SQLite3 friendly? As a bonus, I'd like to be able to also run in PostgreSQL with the same query, but appreciate that might not be possible