THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL CHAR_LENGTH() Function

❮ MySQL Functions

Example

Return the length of the string:

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

Definition and Usage

The CHAR_LENGTH() function returns the length of the specified string (in characters).

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

Note: This function is equal to the CHARACTER_LENGTH() function.

Syntax

CHAR_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:

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

❮ MySQL Functions