
- 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
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?
We know that MySQL RAND() returns a random floating point value between the range of 0 and 1. It will generate two different random numbers if we will call the RAND() function, without seed, two times in the same query. Following example will make it clearer −
Example
mysql> Select RAND(), RAND(), Rand(); +--------------------+-------------------+--------------------+ | RAND() | RAND() | Rand() | +--------------------+-------------------+--------------------+ | 0.9402844448949066 | 0.911499003797303 | 0.7366417150354402 | +--------------------+-------------------+--------------------+ 1 row in set (0.00 sec)
The above result set shows that RAND() function will generate different random number every time we call it.
- Related Articles
- Excel random data: generate random numbers, texts, dates, times in Excel
- How to generate random numbers between two numbers in JavaScript?
- How can I generate two separate outputs using Random in Java
- How can we generate the same sequence of random numbers in MySQL?
- Generate random numbers in Arduino
- Generate random numbers using C++11 random library
- Generate Random Integer Numbers in Java
- Generate pseudo-random numbers in Python
- How to generate different random numbers in a loop in C++?
- How does Python generate random numbers?
- Java program to generate random numbers
- Generate Random Long type numbers in Java
- Generate random characters and numbers in JavaScript?
- Guide to Generate Random Numbers in Linux
- C++ Program to Generate Random Numbers Using Probability Distribution Function

Advertisements