Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • TRIM mysql function

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 138
    Comment on it

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

    TRIM mysql function is used for trimming a given character even left or right and if not given then both side. If trimming character is not passed with this function then this will remove white space form both side of string. This 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 and if this not specified then spaces are removed.

    Here I am giving some example which will explain you this function clearly-

    mysql> SELECT TRIM('        MySQL         ');
    +--------------------------------+
    | TRIM('        MySQL         ') |
    +--------------------------------+
    | MySQL                          |
    +--------------------------------+
    1 row in set (0.00 sec)
    
    mysql> SELECT TRIM(LEADING '?' FROM '?????MySQL?????');
    +------------------------------------------+
    | TRIM(LEADING '?' FROM '?????MySQL?????') |
    +------------------------------------------+
    | MySQL?????                               |
    +------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> SELECT TRIM(TRAILING '?' FROM '?????MySQL?????');
    +-------------------------------------------+
    | TRIM(TRAILING '?' FROM '?????MySQL?????') |
    +-------------------------------------------+
    | ?????MySQL                                |
    +-------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> SELECT TRIM(BOTH '?' FROM '?????MySQL?????');
    +---------------------------------------+
    | TRIM(BOTH '?' FROM '?????MySQL?????') |
    +---------------------------------------+
    | MySQL                                 |
    +---------------------------------------+
    1 row in set (0.00 sec)
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: