Syntax error How can we generate the same sequence of random numbers in MySQL?

How can we generate the same sequence of random numbers in MySQL?



When invoked with an integer argument, RAND( ) uses that value to seed the random number generator. Each time you seed the generator with a given value, RAND( ) will produce the same sequence of random numbers. Following example will demonstrate it −

Example

mysql> Select RAND(1), RAND(1), Rand(1);
+---------------------+---------------------+---------------------+
| RAND(1)             | RAND(1)             | Rand(1)             |
+---------------------+---------------------+---------------------+
| 0.40540353712197724 | 0.40540353712197724 | 0.40540353712197724 |
+---------------------+---------------------+---------------------+
1 row in set (0.00 sec)
Updated on: 2020-06-20T13:01:46+05:30

260 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements