FLOOR(x)返回小于x的最大整数值
RAND()返回0到1内的随机值
CONCAT(aaa,bbb) 链接字符串
FLOOR(3 + (RAND() * 6))在4后面添加一个3到6之间的整数
CONCAT(343,FLOOR(3 + (RAND() * 6)))
---------------------------------------------------------------------
Returns a random floating-point value v between 0 and 1 inclusive (that is, in the range 0 <= v <= 1.0). If an integer argument N is specified, it is used as the seed value, which produces a repeatable sequence.
mysql> SELECT RAND();
-> 0.9233482386203
mysql> SELECT RAND(20);
-> 0.15888261251047
mysql> SELECT RAND(20);
-> 0.15888261251047
mysql> SELECT RAND();
-> 0.63553050033332
mysql> SELECT RAND();
-> 0.70100469486881
mysql> SELECT RAND(20);
-> 0.15888261251047
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 of 7 to 12 inclusive, you could use the following statement:
SELECT FLOOR(7 + (RAND() * 5));
将discuz论坛中所有贴子的浏览数改为13~93之间
update cdb_threads set views=FLOOR( 13+(RAND() * 80));