Category: UPDATE
Random value per row
NewId is good for this as it acts per row:
Ternary Operator if( , , )
if(Condition, ConditionIsTrue, ConditionIsNotTrue) SELECT depending on condition UPDATE depending on condition Example – Increment value if below # or reset to 1
Update From Row + Value Array
DateTime INSERT UPDATE
Set value to Now +- time period Argument can be: MICROSECOND SECOND MINUTE HOUR DAY WEEK MONTH QUARTER YEAR
DateTime
INSERT or UPDATE row to be Now + # Days Some of the values you can use: DAYHOURMINUTEMONTHSECONDWEEKYEAR Update a DateTime with a random value
Numeric values
Increment Decrement but don’t go below a value GREATEST allows you to specify that the greater of multiple values should used. So in this example if the value drops below zero, zero will be greater used: Increment but don’t go above a value LEAST allows you to specify that the lower of multiple values should […]
Null
WHERE statements UPDATE statements
INSERT or UPDATE ON DUPLICATE
Object Oriented Style Insert Or Update If Already Present (Update if primary keys are not unique) Insert Or Update If Already Present WHERE You can ‘t use WHERE with ON DUPLICATE KEY UPDATE. A typical solution is to use a double operation instead, INSERT IGNORE followed by and UPDATE WHERE Insert or Do Nothing If […]
.UPDATE general
Object Oriented Style How many rows were affected Procedural Style Maths Operations In Update Queries Add text to an existing text field