I have a 200k rows mysql table, and a column with empty value, and i like to populate this column with random numbers from 1 to 10,000.
I don't know if its possible to have a query something like this:
UPDATE 'videos'
SET 'views' = rand(1,10000)
UPDATE yourTableName set yourColumnName=value where yourColumnName2=(SELECT FLOOR(1+RAND()*3)); In the above query, the statement FLOOR(1+RAND()*3) generates the number between 1-3 and update the column.
SQL Server RAND() Function The RAND() function returns a random number between 0 (inclusive) and 1 (exclusive).
There are a couple of ways to do it. INSERT INTO students (id, score1, score2) VALUES (1, 5, 8), (2, 10, 8), (3, 8, 3), (4, 10, 7) ON DUPLICATE KEY UPDATE score1 = VALUES(score1), score2 = VALUES(score2);
RAND()
produces random float values from 0 to 1. Could you try this?
Update videos set views = CAST(RAND() * 10000 AS UNSIGNED)
Try this one. It can generate a random number between 1 to 10000.
UPDATE videos
SET views = FLOOR(rand() * 10000) + 1;
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