Common code
Update ' table name ' Set click=click*0.01 where classid= ' 2 ' and click>2000
We often encounter random problems, and here's a way to solve random numbers.
When constructing test data, we need to insert random data into the test table. The method for constructing test data is as follows, with update as an example
Step 1: The SQL function for the random number is rand (), and Rand () produces a decimal between 0-1.
Step 2: *10 rand ()
A decimal number between 1-10 is generated and can be converted using Ceil.
Step 3: Use cast to do type conversion
The use of cast is as follows:
Cast (value as type)
Binary, with the effect of BINARY prefix: BINARY
Character type, with parameters: CHAR ()
Dates: Date
Time: Times
Date-time: DATETIME
Floating point numbers: 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