① sql中replace的實際應用
update G_Guest
set G_Guest.Tel = REPLACE (G_Guest.Tel,8,0)
② 如何對sql資料庫中的某一欄位進行替換
update 表名 set 列1='yr' where 列1='hr'
如果換成REPLACE函數的話,具體語句如下:
update 表名 set 列1=replace(列1,'hr','yr') where 列1='hr'
以上語句的測試過了。
③ SQl語句 select replace(replace('[temp.mobile1]',char(10),''),char(13),'') 這個什麼意思
語法
replace
(
'string_expression1'
,
'string_expression2'
,
'string_expression3'
)
參數
'string_expression1'
待搜索的字元串表達式。string_expression1
可以是字元數據或二進制數據。
'string_expression2'
待查找的字元串表達式。string_expression2
可以是字元數據或二進制數據。
'string_expression3'
替換用的字元串表達式。string_expression3
可以是字元數據或二進制數據。
replace是替換的函數,其中第一個是執行替換的串,第一個是被替換的關鍵字,第二個是以哪個字元串替換掉。比如replace('123sss45','23','bb')實現把傳中的23替換成bb,結果是1bbsss45。
你這個是使用兩次替換,char(10)對應回車符號,char(13)對應換行符號。
這個查詢的結果就是把[temp.mobile1]這個欄位中的回車換行符號使用空來替代,也可以說是把這個欄位中的回車換行符號去掉。
④ replace MYSQL字元替換函數sql語句分享(正則判斷)
復制代碼
代碼如下:
Update
dede_addonsoft
SET
dxylink=REPLACE(dxylink,
'.zip',
'.rar')
where
aid
>
45553;
復制代碼
代碼如下:
update
`table_name`
set
field
=
replace(field,'.rar','.7z');
table_name:要查詢的表名,
field:表裡的欄位名,
replace(field,'.rar','.7z');
:正則匹配,把field欄位里的
.rar
替換為
.7z
MySQL正則表達式替換,字元替換方法
兩句SQL,都是字元替換,比較好用。
update
comment
set
url=IF(url
REGEXP
'test.yahoo.com.cn',REPLACE(url,'www1.sohu.com','www.sina.com'),REPLACE(url,'www2.yahoo.com','www.sina.com'))
where
1=1;
update
comment
set
author_url=REPLACE(author_url,'sohu','sina')
where
author_url
REGEXP
'www.sohu.com';
MySQL
replace函數替換字元串
MySQL
replace函數我們經常用到,下面就為您詳細介紹MySQL
replace函數的用法,希望對您學習MySQL
replace函數方面能有所啟迪。
最近在研究CMS,在數據轉換的時候需要用到mysql的MySQL
replace函數,這里簡單介紹一下。
比如你要將表
tb1裡面的
f1欄位的abc替換為def
UPDATE
tb1
SET
f1=REPLACE(f1,
'abc',
'def');
REPLACE(str,from_str,to_str)
在字元串
str
中所有出現的字元串
from_str
均被
to_str替換,然後返回這個字元串:
mysql>
SELECT
REPLACE('www.mysql.com',
'w',
'Ww');
->
'WwWwww.mysql.com'
這個函數是多位元組安全的。
示例:
UPDATE
`dede_addonarticle`
SET
body
=
REPLACE
(
body,
'</td>',
''
);
UPDATE
`dede_addonarticle`
SET
body
=
REPLACE
(
body,
'</tr>',
''
);
UPDATE
`dede_addonarticle`
SET
body
=
REPLACE
(
body,
'<tr>',
''
);
UPDATE
`dede_archives`
SET
title=
REPLACE
(
title,
'大洋新聞
-
',
''
);
UPDATE
`dede_addonarticle`
SET
body
=
REPLACE
(
body,
'../../../../../../',
'http://special.dayoo.com/meal/'
);
mysql
replace
用法1.replace
intoreplace
into
table
(id,name)
values('1','aa'),('2','bb')
此語句的作用是向表table中插入兩條記錄。
2.replace(object,
search,replace)
把object中出現search的全部替換為replaceselect
replace('www.163.com','w','Ww')--->WwW
www.163.com
例:把表table中的name欄位中的
aa替換為bbupdate
table
set
name=replace(name,'aa','bb')