mysql表中依据一个字段更新另一个字段

判断字段是否存在值,如果不存在则写入本行中另一个字段值。
update table_name set new_column= case when (new_column=0) then old_column else new_column end
即:如new_column不存在值则更新为old_column

Tags: mysql

添加新评论