Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • what is the use of LEN() function in MySQL?

    • 0
    • 1
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 335
    Comment on it

    In MySQL, LEN() function is used to return the length of the value in a column (text field) in a table.

    LEN() Syntax

    SELECT LEN(column_name) FROM table_name;
    

    We have a table "employee" as below:

        employee
        id  first_name            last_name       address
        .......................................................
        1   John                     Simp         Transit highway, Ottawa
        2   Chris                    Hely         Old Servey Road
        3   Joy                      Roy          IT park, Dehradun
        4   Jenny                    Mill         Dehradun
    

    LEN() Example

    The below query selects the "first_name" and the length of the value inside the "address" column from the "employee" table:

    SELECT first_name,LEN(address) as length_of_address FROM employee;
    

    Result:

        first_name            length_of_address
        .......................................................
        John                  23
        Chris                 15
        Joy                   17
        Jenny                 8
    

    Hope this will help you :)

 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: