1、替换数据库特定字段中部分特定数据的SQL语句
SQL语句:update 表名
set 字段名
= replace(字段名
,‘原字符串’,需要替换成的字符串’)
以将表exam_major
中的字段pos2019
中的数据 50 替换成 100 为例:
在查询中运行update exam_major
set pos2019
= replace (pos2019
, ‘50’, ‘100’)
2、批量将数据库中特定字段中的NULL替换为0
SQL语句:update 表名
set 表名
.字段名
=ifnull( 表名
.字段名
,0)
以表exam_major
中的字段first_discipline
为例:
在查询中运行update exam_major
set exam_major
.first_discipline
=ifnull( exam_major
.first_discipline
,0)