lundi 9 juillet 2018

mysql update random a column

How can you randomly update a table. And give a column a random value. But the column (in example 'top') is unique. and if you choose between the numbers 10 to 20 and you have 10 rows that you can't have a number that isn't used. If you have

Test table
-Id-    -Top-
0        0
1        0
2        0
3        0

Can change randomly the column 'top' (1 to 4)

Test table
-Id-    -Top-
0        4
1        1
2        3
3        2

Can anyone help me? thanks a lot.




Aucun commentaire:

Enregistrer un commentaire