Recently in the database on the random number, really touch I want to die heart all have, before all through the rand () function of PHP to deal with a range of random numbers, but recently in the processing of large amounts of data processing millions by PHP too slow, forced, only to find the SQL own processing method.
Body Correlation function ROUND () RAND ()
Let's start by analyzing the meaning of round () and Rand ().
Round () is the method used to take the number of digits after the decimal point, and the returned value is rounded.
Round (A, b) where a represents the number of processed numbers, such as 20.9, 55.08, 33, etc., the number of digits reserved
Round (21.2,0) represents the integer portion of 21.2 + 0 digits after the decimal point, that is, the result is 21, rounded.
Rand () is a repeatable random number that takes directly within a 0~1
topic comes, gets the random number in the specified range
Round (rand () *n+1,0) haha
To parse is to take a repeatable integer within a 1~n+1.
Done
Random range processing method for SQL Server random numbers