![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
Advertisements