Apply WHERE :
UPDATE mytable SET col1 = 10 WHERE col1 = 20
However, if your update is more complex and you really need a few CASE , you need to either bite the bullet, omit WHERE , or add all the columns in WHERE that you want to update:
UPDATE mytable SET col1 = CASE WHEN (col1 = 20) THEN 10 ELSE col1 END, SET col2 = CASE WHEN (col2 = 40) THEN 20 ELSE col2 END, SET col3 = CASE WHEN (col3 = 80) THEN 30 ELSE col3 END WHERE col1 = 20 OR col2 = 40 OR col3 = 80
This can still βupdateβ the columns unnecessarily (for their old values), but not for full rows.
source share