Home >Database >Mysql Tutorial >How to generate the same sequence of random numbers in MySQL?

How to generate the same sequence of random numbers in MySQL?

王林
王林forward
2023-09-09 09:17:07511browse

如何在 MySQL 中生成相同的随机数序列?

When called with an integer argument, RAND( ) uses that value as the seed for the random number generator. RAND( ) generates the same sequence of random numbers each time the generator is seeded with a given value. The 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)

The above is the detailed content of How to generate the same sequence of random numbers in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete