Update if different/changed

后端 未结 8 2043
野性不改
野性不改 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:18

    You need an unique key id in your table, (let's suppose it's value is 1) to do something like:

    UPDATE table1 SET col1="hello" WHERE id=1 AND col1!="hello"
    

提交回复
热议问题