mysql replaces the sql statement of the string in the table
- 2020-05-06 11:48:14
- OfStack
Core statement:
UPDATE `cdb_pms`
SET `subject` = REPLACE(`subject`, 'Welcome to', ' welcome ')
mysql replaces the string
in the data content part of the field
mysql replaces the contents of the table's fields, as in the example
mysql
>
select host,user from user where user='testuser';
+-----------------------+----------+
| host | user |
+-----------------------+----------+
| localhost.localdomain | testuser |
+-----------------------+----------+
For the update field host, change "main" to "slave" and use REPLACE
mysql
>
update user set host=REPLACE(host,'main','slave') where user='testuser';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql
>
select host,user from user where user='testuser';
+------------------------+----------+
| host | user |
+------------------------+----------+
| localhost.localdoslave | testuser |
+------------------------+----------+
From the query result to, the data has been updated successfully
dede does not alternate well because the server is equipped with a first-class interceptor system. SQL:
can only be manually installed in phpadmin
update dede_addonarticle set body=replace(body ,' method ')
mysql replaces the contents in the table's fields, as in example:
mysql
>
select id,type from items limit 10;
+--------+--------+
| id | type |
+--------+--------+
| 0001 | 780000 |
| 0002 | 780000 |
| 0003 | 780000 |
| 0004 | 780000 |
| 0005 | 780000 |
| 150419 | 780000 |
| 150420 | 780000 |
| 150421 | 780000 |
| 150422 | 780000 |
| 150423 | 780000 |
+--------+--------+
Change the "78" in the type field to "79" using the replace function
sql is as follows:
mysql > update items set type=replace(type,'79','78');
Query OK, 17536 rows affected (0.72 sec)
Rows matched: 17536 Changed: 17536 Warnings: 0
Further enquiry:
mysql
>
select id,type from items limit 10;
+--------+--------+
| id | type |
+--------+--------+
| 0001 | 790000 |
| 0002 | 790000 |
| 0003 | 790000 |
| 0004 | 790000 |
| 0005 | 790000 |
| 150419 | 790000 |
| 150420 | 790000 |
| 150421 | 790000 |
| 150422 | 790000 |
| 150423 | 790000 |
+--------+--------+
10 rows in set (0.00 sec)
From the query result to, the data has been updated successfully