Trim() 函式的介紹【Blog 搬家】

myhuaer發表於2010-05-05

Trim() 函式的介紹

2005 年 12 月 03日, 星期六

Trim()
很多人對Trim()函式的用法僅僅限於去掉兩邊空格。下面讓大家看看Trim()到底能幫我們作些什麼/

TRIM 可以去掉字串中開頭或結尾(或全部)的字元的某個字元。必須要將去掉的字元放在'' 之間。
如果不寫某些字元則會字串兩邊的空格(space) 去掉。


INSERT into demo values('weather',1,'lis',N'天氣')
insert into demo values('waiwai',1,'lis',N'外外')
insert into demo values('waiwai11w',1,'lis',N'外外')

select name,trim(leading 'w' from name) for_test from demo
"NAME" "FOR_TEST"
"wether" "ether"
"waiwai11w" "aiwai11w"
"weather" "eather"


select name,trim(TRAILING 'w' from name) for_test from demo
"NAME" "FOR_TEST"
"wether" "wether"
"waiwai" "waiwai"
"waiwai11w" "waiwai11"
"weather" "weather"

select name,trim(both 'w' from name) for_test from demo

"NAME" "FOR_TEST"
"wether" "ether"
"waiwai" "aiwai"
"waiwai11w" "aiwai11"
"weather" "eather"

select name ,trim(name) for_test from demo
"NAME" "FOR_TEST"
"wether" "wether"
"waiwai" "waiwai"
"waiwai11w" "waiwai11w"
"weather" "weather"


myhuaer 發表於:2005.12.03 11:04 ::分類: ( Oracle Infomation ) ::閱讀:(469次)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/34596/viewspace-661939/,如需轉載,請註明出處,否則將追究法律責任。

相關文章