Each time you seed the generator with a given value, RAND( ) will produce a repeatable series of numbers: : RAND « Function « SQL / MySQL






Each time you seed the generator with a given value, RAND( ) will produce a repeatable series of numbers:

     
mysql>
mysql> SELECT RAND(1), RAND( ), RAND( );
+-------------------+-------------------+-------------------+
| RAND(1)           | RAND( )           | RAND( )           |
+-------------------+-------------------+-------------------+
| 0.405403537121977 | 0.460129410456987 | 0.438083880988959 |
+-------------------+-------------------+-------------------+
1 row in set (0.00 sec)

mysql>
mysql> SELECT RAND(20000000), RAND( ), RAND( );
+-------------------+-------------------+-------------------+
| RAND(20000000)    | RAND( )           | RAND( )           |
+-------------------+-------------------+-------------------+
| 0.339101235698072 | 0.810031204307481 | 0.735904409304172 |
+-------------------+-------------------+-------------------+
1 row in set (0.00 sec)

mysql>
mysql> SELECT RAND(1), RAND( ), RAND( );
+-------------------+-------------------+--------------------+
| RAND(1)           | RAND( )           | RAND( )            |
+-------------------+-------------------+--------------------+
| 0.405403537121977 | 0.249428464332063 | 0.0394291244814444 |
+-------------------+-------------------+--------------------+
1 row in set (0.00 sec)

mysql>
mysql> SELECT RAND(20000000), RAND( ), RAND( );
+-------------------+-------------------+-------------------+
| RAND(20000000)    | RAND( )           | RAND( )           |
+-------------------+-------------------+-------------------+
| 0.339101235698072 | 0.448860260144677 | 0.126013958012698 |
+-------------------+-------------------+-------------------+
1 row in set (0.00 sec)

mysql>

   
    
    
    
    
  








Related examples in the same category

1.Selection with a random Column
2.To select a single winner at random from the combined results of the three tables
3.Generating Random Numbers
4.Seed RAND( ) randomly
5.Randomizing a Set of Rows
6.Add a column of random numbers to the column output list, alias it, and refer to the alias for sorting
7.Selecting Random Items from a Set of Rows
8.To draw five winning entries at random from a table named drawing that contains contest entries, use RAND( ) i
9.get some random numbers
10.Get some random numbers in the range 1-100
11.Get the name and the number of each player whose name consists of the pattern m.n. The point can be any random