I want update my table with random values from given set, not from another table.
e.g. value1, value2, value3
and MySQL query should be update all records from above values.
I am looking similar type of solution but with random string values from given set: Update column with random value
I would use the elt()
function:
update tablename
set columnname = elt(floor(rand()*3) + 1, 'value1', 'value2', 'value3');
elt()
chooses a particular element from a list. rand()
produces a random values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With