To obtain a random integer R in the range i <= R < j, use the expression FLOOR(i + RAND() * (j â€“ i)). For example, to obtain a random integer in the range the range 7 <= R < 12, you could use the following statement:

SELECT FLOOR(7 + (RAND() * 5));