The function of floor() function is to return the maximum value that is less than or equal to this value. Integer
Example: select floor(1.1) from qs_ad_category
The result of the above query statement is 1. Since the maximum integer smaller than 1.1 is 1, the result is 1
Note: Limitations of the floor() function: mysql 5.0 and above
The role of the rand() function: Get a random floating point number (a decimal less than 0), while rand(0) gets a fixed decimal value
Example: select rand() from qs_ad_category ;
The result is a random floating-point decimal: 0.7450851357961866
##3. The floor() function cooperates with the rand() function3.1 The use of two combined functionsSince the rand() function obtains a floating point number less than 1, that is, for example, 0.7450851357961866 in the above resultFloor() function rounds down the value inside the parentheses to the nearest integer that is less than or equal to it, and displays the result.. For example, the result of rand() above is 0.7450851357961866, then the maximum integer is "0", so: select floor(rand(0)) from qs_ad_category The result value is "0". If it is rand()*2, the rand() result may be greater than 1, then combined with the floor() function, the final value may be 1select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables
使用报错获取当前用户信息 select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x
The above is the detailed content of How to use the error function floor() function and rand() function together in Mysql. For more information, please follow other related articles on the PHP Chinese website!