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)