Home >Database >Mysql Tutorial >How to use the error function floor() function and rand() function together in Mysql
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
select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables4. Use the floor() function Mainly error injection4.1 Components of error injectionfloor() Accurately speaking, error injection should be floor, count, group by conflict error, count(*), rand() , group by are indispensable4.2 Error injection component analysiscount() function: counting function, a function used to calculate the sum of data, this function has only one result set. floor() function rand() function: Get the integer value of 0 or 1 group by function: When grouping data, it will first check whether the value exists in the virtual table, no If it exists, insert it; if it exists, count() will be incremented by 1. When using group by, floor(rand(0)2) will be executed once. If there is no record in the virtual table, it will be executed again when inserting into the virtual table. 4.3 Display error injection
使用报错获取当前用户信息 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!