How can we get a random number between 1 and 100 in MySQL?

In MySQL we have a RAND() function that returns a random number between 0 and 1.

SELECT RAND();

If we want to get a random number between 1 and 100, we can use following query:

SELECT RAND() * 100;

Read the full book at www.amazon.com
Posted in MySQL, MySQL Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *

*