MySQL LENGTH() Function
THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL LENGTH() Function

❮ MySQL Functions

Example

Return the length of the string, in bytes:

SELECT LENGTH("SQL Tutorial") AS LengthOfString;
Try it Yourself »

Definition and Usage

The LENGTH() function returns the length of the specified string (in bytes).

Note: When using this function, a multi-byte character is counted as more than one byte.

Syntax

LENGTH(string)

Parameter Values

Parameter Description
string Required. The string to return the length for

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

More Examples

Example

Return the length of the text in the "CustomerName" column, in bytes:

SELECT LENGTH(CustomerName) AS LengthOfName
FROM Customers;
Try it Yourself »

❮ MySQL Functions