We often encounter the problem of using random numbers, and here is a way to solve a random number.
When constructing the test data, we need to insert random data into the test table. The method of constructing the test data is as follows, only the update example illustrates
Step 1: The SQL function for the random number is rand (), and Rand () generates a decimal between 0-1.
Step 2: Put rand () *10
Step 3: Use cast for type conversion
The use of cast is as follows:
Cast (value as type)
Binary, with binary prefix effect: binary
Character type, with parameters: CHAR ()
Date: Date
Time:
DateTime Date/Time type
Floating point number: DECIMAL
Integer: Signed
unsigned integer: UNSIGNED
SELECT CAST (rand () *10 as signed) as RAND
Step 4: Run the SQL statement
UPDATE Storm_effect_info S SET
S.FHTP = (SELECT CAST (rand () *10 as signed) as RAND) WHERE s.id = 13
Inserting random numbers into MySQL database