MySQL 如何将+(加号)替换为空格
使用MySQL的REPLACE()函数进行替换。首先创建一个表 –
mysql> create table DemoTable
(
Number varchar(100)
);
Query OK, 0 rows affected (0.86 sec)
使用插入命令向表中插入一些记录 –
mysql> insert into DemoTable values('+916578675547');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable values('+918976676564');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable values('+919800087678');
Query OK, 1 row affected (0.12 sec)
使用SELECT语句显示表中的所有记录 –
mysql> select *from DemoTable;
这将产生以下输出 –
+---------------+
| Number |
+---------------+
| +916578675547 |
| +918976676564 |
| +919800087678 |
+---------------+
3 rows in set (0.00 sec)
以下是将“+”(加号)替换为空格的查询 –
mysql> update DemoTable set Number=replace(Number, '+', ' ');
Query OK, 3 rows affected (0.12 sec)
Rows matched: 3 Changed: 3 Warnings: 0
再次检查表记录 –
mysql> select *from DemoTable
这将产生以下输出 –
+---------------+
| Number |
+---------------+
| 916578675547 |
| 918976676564 |
| 919800087678 |
+---------------+
3 rows in set (0.00 sec)
阅读更多:MySQL 教程