Remove the left space function from the powerful mysql trim () function bitsCN. commysql:
LTRIM (str)
Returns the string str with leading space characters removed.
The following is a code snippet:
Mysql> select ltrim ('barbar ');
-> 'Barbar'
This function is multi-byte safe.
Remove right spaces in mysql:
RTRIM (str)
Returns the string str with trailing space characters removed.
The following is a code snippet:
Mysql> select rtrim ('barbar ');
-> 'Barbar'
This function is multi-byte safe.
The trim function can filter specified strings:
Complete format: TRIM ([{BOTH | LEADING | TRAILING} [remstr] FROM] str)
Simplified Format: TRIM ([remstr FROM] str)
Returns the string str with all remstr prefixes or suffixes removed. if none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.
The following is a code snippet:
Mysql> select trim ('bar'); // spaces before and after deletion by default
-> 'Bar'
Mysql> select trim (LEADING ', 'from', barxxx'); // delete the specified first character, such ','
-> 'Barxxx'
Mysql> select trim (BOTH ', 'from', bar,'); // deletes the specified start and end characters.
-> 'Bar'
Mysql> select trim (TRAILING ',' FROM 'barxxyz ,,');
-> 'Barxxyz'
Mysql> UPDATE table SET 'field' = TRIM (TRAILING ', 'From 'field') WHERE 'field' LIKE '% ,';
This function is multi-byte safe.
Replace the last paging character of the field in the database
UPDATE [! Db. pre!] Ecms_news_data_1 SET 'newstext '= TRIM (TRAILING 'bitscn. com
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.