Mathematical Functions RAND()  in a  WHERE  clause is evaluated for every row (when selecting from one table) or combination of rows (when selecting from a multiple-table join). Thus, for optimizer purposes,  RAND()  is not a constant value and cannot be used for index optimizations. For more information, see Section 8.2.1.20, “Function Call Optimization” . Use of a column with  RAND()  values in an  ORDER BY  or  GROUP BY  clause may yield unexpected results because for either clause a  RAND()  expression can be evaluated multiple times for the same row, each time returning a different result. If the goal is to retrieve rows in random order, you can use a statement like this: To select a random sample from a set of rows, combine  ORDER BY RAND()  with  LIMIT : RAND()  is not meant to be a perfect random generator. It is a fast way to generate random numbers on demand that is portable between platforms for the same MySQL version. This function is unsafe for statement-based replication. A warning is logged if you use this function when binlog_format  is set to  STATEMENT . Rounds the argument  X  to  D  decimal places. The rounding algorithm depends on the data type of  X .  D defaults to 0 if not specified.  D  can be negative to cause  D  digits left of the decimal point of the value  X  to become zero. The maximum absolute value for  D  is 30; any digits in excess of 30 (or -30) are truncated. mysql>  SELECT ROUND(-1.23); -> -1 mysql>  SELECT ROUND(-1.58); -> -2 mysql>  SELECT ROUND(1.58); -> 2 SELECT * FROM table1, table2 WHERE a=b AND c<d ORDER BY RAND() LIMIT 1000; SELECT * FROM  tbl_name  ORDER BY RAND(); 2147 • ROUND( X ) ,  ROUND( X , D ) mysql>  SELECT i, RAND() FROM t; mysql>  SELECT i, RAND(3) FROM t; 3 rows in set (0.00 sec) 3 rows in set (0.01 sec) +------+------------------+ | i | RAND(3) | +------+------------------+ | 1 | 0.90576975597606 | | 2 | 0.37307905813035 | | 3 | 0.14808605345719 | +------+------------------+ +------+------------------+ | i | RAND() | +------+------------------+ | 1 | 0.35877890638893 | | 2 | 0.28941420772058 | | 3 | 0.37073435016976 | +------+------------------+ +------+------------------+ | i | RAND(3) | +------+------------------+ | 1 | 0.90576975597606 | | 2 | 0.37307905813035 | | 3 | 0.14808605345719 | +------+------------------+ 3 rows in set (0.00 sec)