SQL TRIM()函數

TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)

TRIM([remstr FROM] str)

返回字符串str,刪除了所有使用Remstar前綴或後綴。如果沒有說明符BOTH,LEADING,或TRAILING給出,BOTH是假定(默認)的。Remstar是可選的,如果未指定,空格被刪除。

SQL> SELECT TRIM(' bar '); +---------------------------------------------------------+ | TRIM(' bar ') | +---------------------------------------------------------+ | bar | +---------------------------------------------------------+ 1 row in set (0.00 sec) SQL> SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx'); +---------------------------------------------------------+ | TRIM(LEADING 'x' FROM 'xxxbarxxx') | +---------------------------------------------------------+ | barxxx | +---------------------------------------------------------+ 1 row in set (0.00 sec) SQL> SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx'); +---------------------------------------------------------+ | TRIM(BOTH 'x' FROM 'xxxbarxxx') | +---------------------------------------------------------+ | bar | +---------------------------------------------------------+ 1 row in set (0.00 sec) SQL> SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz'); +---------------------------------------------------------+ | TRIM(TRAILING 'xyz' FROM 'barxxyz') | +---------------------------------------------------------+ | barx | +---------------------------------------------------------+ 1 row in set (0.00 sec)

0 條評論,你可以發表評論,我們會進行改進
Comment author placeholder