From manual:

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));

RAND() in a WHERE clause is re-evaluated every time the WHERE is executed.

 
cheat-sheets/mysql/get-random-integer.txt · Last modified: 2009/11/30 01:18 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki