I suppose this will be easy to MySQL pros. Given an existing filled MySQL-InnoDB table like
key1 | key2 | foobar | position
where key1 and key2 together make up the primary key, and position is mostly still NULL, with what SQL would I best fill the "position" field with a randomly ordered but iterated integer value? E.g. if there were 4 rows, then I would want to have (just as an example order):
3
1
4
2
Background: I want to display the table to the user in a web app, and the order should be static but random, i.e. once decided randomly but then with a predictable order. Sometimes I need to completely reshuffle the order, though, while the rest of the table remains intact. Also, I sometimes need to add a couple of rows to the table with new positions, but these new rows must not be given a position lower than any existing ones, hence the need to have it be iterated, and not say using a completely random float.