FLOORRAND 65535 - 20000 + 1 + 20000
The expression "FLOOR(RAND() * (65535 - 20000 + 1) + 20000)" generates a random integer between 20000 and 65535 (inclusive).
Here's an example of how it works:
- Calculate the difference between the upper and lower limits: (65535 - 20000 + 1) = 45536.
- Generate a random decimal number between 0 and 1 using the RAND() function.
- Multiply the random decimal number by the difference calculated in step 1: RAND() * 45536.
- Add the lower limit (20000) to the result obtained in step 3: RAND() * 45536 + 20000.
- Apply the FLOOR function to round down the result obtained in step 4 to the nearest integer: FLOOR(RAND() * 45536 + 20000).
By doing this, you will obtain a random integer between 20000 and 65535
原文地址: https://www.cveoy.top/t/topic/hyjy 著作权归作者所有。请勿转载和采集!