MySQL RAND() Function: Generate Random Numbers
In MySQL, you can use the RAND() function to generate a random number. The RAND() function generates a random floating-point number between 0 and 1. If you need to generate a random number within a specific range, you can use the following formula:
SELECT FLOOR(MIN + RAND() * (MAX - MIN)) AS random_number
MIN and MAX represent the minimum and maximum values of the required range of random numbers.
For example, to generate a random integer between 1 and 100, you can execute the following SQL statement:
SELECT FLOOR(1 + RAND() * 100) AS random_number