mysql更新某一列數據

UPDATE 表名 SET 字段名 = REPLACE(替換前的字段值, '替換前關鍵字', '替換後關鍵字');html

 select * from province;
+----+------------------+---------------------------------------------------------------+
| id | name             | url                                                           |
+----+------------------+---------------------------------------------------------------+
|  1 | 北京市           | http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2018/11.html |
|  2 | 天津市           | http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2018/12.html |
|  3 | 河北省           | http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2018/13.html |
|  4 | 山西省           | http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2018/14.html |
|  5 | 內蒙古自治區     | http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2018/15.html |
|  6 | 遼寧省           | http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2018/21.html |
|  7 | 吉林省           | http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2018/22.html |
 update province set url = replace(url,"*",null);
Query OK, 31 rows affected (0.03 sec)
Rows matched: 31  Changed: 31  Warnings: 0
 select * from province;
+----+------------------+------+
| id | name             | url  |
+----+------------------+------+
|  1 | 北京市           | NULL |
|  2 | 天津市           | NULL |
|  3 | 河北省           | NULL |
|  4 | 山西省           | NULL |
|  5 | 內蒙古自治區     | NULL |
|  6 | 遼寧省           | NULL |
|  7 | 吉林省           | NULL |

 

轉載於:https://www.cnblogs.com/a-s-m/p/10767142.htmlpost