整批更新欄位裡的字串

回覆文章
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

整批更新欄位裡的字串

文章 yehlu »

因資料有" 造成匯出 CSV 資料位移了
解決方式將 " 改為 吋

http://topic.csdn.net/t/20041028/14/3499745.html

代碼: 選擇全部

update prod set prod_name=replace(prod_name,'"','吋')WHERE prod_name LIKE '%"%'
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: 整批更新欄位裡的字串

文章 yehlu »

代碼: 選擇全部

mysql> update cust set addr =  replace(addr,'鄉','區')  where addr like '台中縣%';
Query OK, 95 rows affected (0.01 sec)
Rows matched: 157  Changed: 95  Warnings: 0

mysql> update cust set addr =  replace(addr,'市','區')  where addr like '台中縣%';
Query OK, 51 rows affected (0.00 sec)
Rows matched: 157  Changed: 51  Warnings: 0

mysql> update cust set addr =  replace(addr,'鎮','區')  where addr like '台中縣%';
Query OK, 11 rows affected (0.01 sec)
Rows matched: 157  Changed: 11  Warnings: 0

mysql> update cust set addr =  replace(addr,'縣','市')  where addr like '台中縣%';
Query OK, 157 rows affected (0.01 sec)
Rows matched: 157  Changed: 157  Warnings: 0
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: 整批更新欄位裡的字串

文章 yehlu »

代碼: 選擇全部

mysql> update cust set addr =  replace(addr,'市','區')  where addr like '台北縣%';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> update cust set addr =  replace(addr,'台北縣','新北市')  where addr like '台北縣%';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

aryshia
文章: 1
註冊時間: 2015-01-08 20:02:50

Re: 整批更新欄位裡的字串

文章 aryshia »

索引可以加快查尋速度,以平衡樹結構存放索引資料 .
例如:
sara
回覆文章

回到「MySQL」