Im trying to count the number of rows in the table and generate random numbers for the field ‘random’
Now this works:
SELECT COUNT(*) FROM my_table;
and this works:
UPDATE my_table SET random = FLOOR(6500 * RAND()) + 1;
But this doesn’t work:
UPDATE my_table SET random = FLOOR((SELECT COUNT(*) ) * RAND()) + 1;
But this counts the rows as 0 and adds one so all fields have the number one instead of a unique random number.
Any ideas what I’m doing wrong would be most helpful.
What about this?
Demo: http://sqlfiddle.com/#!2/a896d/4