laika222
11/4/2016 - 1:29 AM

You can create a random number. Line 2 shows the formula to create a random decimal, where a is the lowest number of the range and b is the

You can create a random number. Line 2 shows the formula to create a random decimal, where a is the lowest number of the range and b is the highest number of the range. Line 6 shows the formula to create a random integer, where a is the lowest number of the range and b is the highest number of the range.

-- RANDOM DECIMAL BETWEEN 10 AND 25
-- SELECT RAND()*(b-a)+a;
SELECT RAND()*(25-10)+10;

-- RANDOM INTEGER BETWEEN 10 AND 25
-- SELECT FLOOR(RAND()*(b-a+1))+a;
SELECT FLOOR(RAND()*(25-10+1))+10;