Ternary Operator if( , , )

if(Condition, ConditionIsTrue, ConditionIsNotTrue) SELECT depending on condition UPDATE depending on condition Example – Increment value if below # or reset to 1

Read More

DateTime

INSERT or UPDATE row to be Now + # Days Some of the values you can use: DAYHOURMINUTEMONTHSECONDWEEKYEAR Update a DateTime with a random value

Read More

Numeric values

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 below a value LEAST allows you to specify that the lower of multiple values should used. […]

Read More

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 […]

Read More

.UPDATE general

Object Oriented Style How many rows were affected Procedural Style Maths Operations In Update Queries Add text to an existing text field

Read More