What's the best way to update an "order" column?
Say I have an id column with 0 to 9, and order column from 0 to 9.
Currently, it's in the database as: 0 0, 1 1, 2 2, etc
My HTML page posts what it wants as the new order: 0 8, 1 3, 2 6, etc. (This is completely random, decided by the user).
What's the best way to make the update?
I can loop through and run an update for each. I can also create a temporary table with all the pairs, and then update based on a subquery.
But I feel like I'm forgetting something trivial that will do this much faster. Any suggestions?
Thanks, Colin