RAND() Function in MySQL


The Rand() function used to return a random floating-point value. RAND(N) used to returns the same value each time. And also returns a repeatable sequence of random numbers.

Syntax
SELECT RAND();
Try it Yourself
Select Random Number from a Range:

For example, To get a random number from 10000 to 99999 use the following query.

Example
SELECT FLOOR(RAND()*(99999-10000)+10000);
Try it Yourself
RAND(N):

RAND(seed). seed is Optional. it returns a repeatable sequence of random numbers.

Example
SELECT RAND(3) from table_name;
Try it Yourself
Select a Random record from a MySQL database.

The following query used to select 10 Random rows from table in a MySQL Database.

Example
SELECT RAND(3) from table_name;
Try it Yourself