How to get mysql random integer range?

后端 未结 4 2138
执笔经年
执笔经年 2020-12-08 06:01

I am trying to generate a random integer for each row I select between 1 and 60 as timer.

SELECT downloads.date, products.*, (FLOOR(1 + RAND() * 60)) AS time         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 06:58

    You can increase the number multiplied by the number of records in the table.

    SELECT id,
    
    (FLOOR( (SELECT MIN(id)                        FROM  your_table ) + RAND( ) * 1000000 ) ) AS timer
    FROM your_table
    LIMIT 0 , 30
    

提交回复
热议问题