Name

RAND( )

Synopsis

RAND([seed])

This function returns a random floating-point number from 0 to 1. A seed number may given with the function, but the results will be the same each time.

SELECT RAND( ), RAND( );
+------------------+------------------+
| RAND( )           | RAND( )           |
+------------------+------------------+
| 0.29085519843814 | 0.45449978900561 |
+------------------+------------------+

Note that rerunning this statement with the same seeds will produce the same results.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.