Let’s say i have two fields a and b.
Now let’s say i want to write a query which would update if a = 100 AND b = 120 else it would create new field.
Also a and b have to be unique to each other, what i mean is that it can be two a equals to 100 or two b equals to 200, but there can’t be more fields like
a = 100 and b = 120, i hope you get what i mean.
If you have a
UNIQUEconstraint on the(a,b)combination, you can use theINSERT ... ON DUPLICATE KEY UPDATE ...syntax for this functionality. Examples: