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?

王林
Release: 2023-09-09 09:17:07
forward
543 people have browsed it

如何在 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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template