I am trying to create a random integer for each line. I choose from 1 to 60 as a timer.
SELECT downloads.date, products.*, (FLOOR(1 + RAND() * 60)) AS timer
I searched and continue to approach this FLOOR function to select a random integer in the range. This gives me 1 for each row. What am I missing?
I'm on mysql 5.0.75
Here is the rest of the request, I suppose it could be a nesting problem
SELECT * FROM ( SELECT downloads.date, products.*, FLOOR(1 + (RAND() * 60)) AS randomtimer, ( SELECT COUNT( * ) FROM distros WHERE distros.product_id = products.product_id ) AS distro_count, (SELECT COUNT(*) FROM downloads WHERE downloads.product_id = products.product_id) AS true_downloads FROM downloads INNER JOIN products ON downloads.product_id = downloads.product_id ) AS count_table WHERE count_table.distro_count > 0 AND count_table.active = 1 ORDER BY count_table.randomtimer , count_table.date DESC LIMIT 10
mysql random
kevzettler Jun 11 '09 at 23:57 2009-06-11 23:57
source share