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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 264
    Comment on it

    SUBSTRING(str,pos), SUBSTRING(str FROM pos), SUBSTRING(str,pos,len), SUBSTRING(str FROM pos FOR len)

    SUBSTRING mysql function returns substring from a string. You can use this function with some above types. If you pass only one argument with string which is position then this function returns the substring from the position which was passed as argument with function. If position is passed with negative (-) sign then position will count from right side of string. If you pass position and length both argument then this will return a substring from position to given length. I am giving some example which will explain this function-

    mysql> SELECT SUBSTRING('Hello MySQL. This is mysql',3);
    +-------------------------------------------+
    | SUBSTRING('Hello MySQL. This is mysql',3) |
    +-------------------------------------------+
    | llo MySQL. This is mysql                  |
    +-------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> SELECT SUBSTRING('Hello MySQL. This is mysql',3,9);
    +---------------------------------------------+
    | SUBSTRING('Hello MySQL. This is mysql',3,9) |
    +---------------------------------------------+
    | llo MySQL                                   |
    +---------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> SELECT SUBSTRING('Hello MySQL. This is mysql' FROM 3);
    +------------------------------------------------+
    | SUBSTRING('Hello MySQL. This is mysql' FROM 3) |
    +------------------------------------------------+
    | llo MySQL. This is mysql                       |
    +------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> SELECT SUBSTRING('Hello MySQL. This is mysql' FROM 3 FOR 9);
    +------------------------------------------------------+
    | SUBSTRING('Hello MySQL. This is mysql' FROM 3 FOR 9) |
    +------------------------------------------------------+
    | llo 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: