Update if different/changed

后端 未结 8 2029
野性不改
野性不改 2020-12-15 02:54

Is it possible to perform an update statement in sql, but only update if the updates are different?

for example

if in the database, col1 = \"hello\"

8条回答
  •  庸人自扰
    2020-12-15 03:29

    Old question but none of the answers correctly address null values.

    Using <> or != will get you into trouble when comparing values for differences if there are is potential null in the new or old value to safely update only when changed use the is distinct from operator in Postgres. Read more about it here

提交回复
热议问题