..


Sponsored Links

TRIM

The MySQL TRIM function serves to eliminate areas that may be present before and after the string passed in argument. Example:

 



 SELECT TRIM ('mrwebmaster);

 
Return:
 



 mrwebmaster

 

The TRIM function can also be used to remove a series of characters (other than space) before, after or both "sides" of a string. To do this we use a slightly more complex syntax based on the keywords:

  • TRAILING (first string)
  • LEADING (after the string)
  • BOTH (both before and after the string)
Let's see some examples:





 SELECT TRIM (TRAILING 'x' FROM 'xxxmrwebmaster');







 SELECT TRIM (LEADING 'x' FROM 'mrwebmasterxxx');







 SELECT TRIM (BOTH 'x' FROM 'xxxmrwebmasterxxx');



See also functions LTRIM and RTRIM

In the same category ...
E-Learning
MS Access (Advanced) MS Access (Advanced)
Learn how to create and manage databases quickly and easily. Starting from 29 €.
MySQL (Course) MySQL (Course)
Management of open-source database. From 39 €.
SQL and Database (Course) SQL and Database (Course)
Create and manage relational databases. From 39 €.
Sponsored Links