Remove left space in mysql:
LTRIM (str)
Returns the string str with leading space characters removed.
The following is a code snippet:
Copy codeThe Code is as follows:
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:
Copy codeThe Code is as follows:
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:
Copy codeThe Code is as follows:
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'
Copy codeThe Code is as follows:
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
Copy codeThe Code is as follows:
UPDATE [! Db. pre!] Ecms_news_data_1 SET 'newstext '= TRIM (TRAILING '[! -- Empirenews. page --] 'FROM 'newstext') WHERE id = 585;
Select trim (TRAILING '[! -- Empirenews. page --] 'FROM 'newstext') AS newstex FROM [! Db. pre!] Ecms_news_data_1 WHERE id = 585;