(1) MySQL replace function
Syntax: replace (object,search,replace)
Meaning: Replace all occurrences of search in object with the Replace
Case:
SQL Code copy content to clipboard
Update ' News ' Set ' content ' = Replace (' content ',',');//clear spaces in the content field in the news table
(2) MySQL trim function
Syntax: Trim ([{BOTH | Leading | TRAILING} [REMSTR] from] str)
The following examples illustrate:
SQL Code copy content to clipboard
mysql> SELECT TRIM (' phpernote ');
' phpernote '
SQL Code copy content to clipboard
-
mysq l> select ' x ' from   ' xxxphpernotexxx '
-
-> phpernotexxx '
sql Code copy content to clipboard
-
mysq l> select ' x ' from   ' xxxphpernotexxx '
-
-> Phpernote '
sql Code copy content to clipboard
mysql> SELECT TRIM (TRAILING ' xyz ' from ' phpernotexxyz ');
' Phpernotex '
<SQL> remove spaces from field data in the database