mysql調換表中的字符串的sql語句。本站提示廣大學習愛好者:(mysql調換表中的字符串的sql語句)文章只能為提供參考,不一定能成為您想要的結果。以下是mysql調換表中的字符串的sql語句正文
焦點語句:
UPDATE `cdb_pms` SET `subject` = REPLACE(`subject`, 'Welcome to', '迎接惠臨')
mysql調換字段裡數據內容部門字符串
mysql調換表的字段外面內容,如例子:
mysql> select host,user from user where user='testuser';
+-----------------------+----------+
| host | user |
+-----------------------+----------+
| localhost.localdomain | testuser |
+-----------------------+----------+
update字段host的內容,把"main"改成"slave",用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 |
+------------------------+----------+
由查詢成果到,數據曾經更新勝利
由於辦事器上安了一流攔阻體系,所以dede的瓜代功效欠好使.只妙手動在phpadmin中SQL:
update dede_addonarticle set body=replace(body ,'年夜法','辦法')
mysql調換表的字段外面內容,如例子:
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 |
+--------+--------+
把type字段中的“78”改成“79” 用replace函數
sql以下:
mysql> update items set type=replace(type,'79','78');
Query OK, 17536 rows affected (0.72 sec)
Rows matched: 17536 Changed: 17536 Warnings: 0
再查詢:
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)
由查詢成果到,數據曾經更新勝利