
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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)
- Related Articles
- How to generate 5 random numbers in MySQL stored procedure?
- How can we generate Strong numbers in Python?
- How to generate random numbers with sequence and store in a data frame column in R?
- How does Python generate random numbers?
- Generate random numbers in Arduino
- How to generate large random numbers in Java?
- How to generate random numbers between two numbers in JavaScript?
- Generate Random Integer Numbers in Java
- Generate pseudo-random numbers in Python
- Generate an integer sequence in MySQL?
- How can I generate random numbers in a given range in Android using Kotlin?
- Generate array of random unique numbers in PHP?
- I am calling RAND() function two times in the same query then will it generate same random number two times or will it generate two different random numbers?
- How to generate non-repeating random numbers in Python?
- How to generate standard normal random numbers in R?

Advertisements