mysql如何获取随机整数范围?
我试图为我在1到60之间选择的每一行生成一个随机整数作为计时器。
SELECT downloads.date, products.*, (FLOOR(1 + RAND() * 60)) AS timer
我已经搜索并继续使用此FLOOR函数作为如何在范围内选择随机整数。这给我每一行1。我想念什么?
我在mysql 5.0.75上
我相信这是查询的其余部分,这可能是一个嵌套问题
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版本可能是?
SELECT id, (FLOOR( 1 + RAND( ) *60 )) AS timerFROM users
LIMIT 0 , 30
以上是 mysql如何获取随机整数范围? 的全部内容, 来源链接: utcz.com/qa/423342.html