MySQL RAND() Function
Example
Return a random decimal number (no seed value - so it returns a completely random number >= 0 and <1):
SELECT RAND();
Try it Yourself »
Definition and Usage
The RAND() function returns a random number or a random number within a range.
The RAND() function will return a value between 0 (inclusive) and 1 (exclusive).
The RAND() function will return a completely random number if no seed is provided, and a repeatable sequence of random numbers if a seed value is used.
Syntax
RAND(seed)
Parameter Values
Parameter | Description |
---|---|
seed | Optional. If specified, it produces a repeatable sequence of random numbers each time that seed value is provided |
Technical Details
Works in: | MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23 |
---|