MySQL CHARACTER_LENGTH Function | Length of String

MySQL CHARACTER_LENGTH is an inbuilt function in MySQL. It returns the length of the input string by counting the number of characters. Also, it ignores whether the characters are single-byte or multi-bytes. It simply counts the number of characters. In this article, we will discuss the MySQL CHARACTER_LENGTH Function.

Note: This function is an alias of MySQL CHAR_LENGTH Function. You can use any one of them interchangeably.




The function expects only one parameter. The string whose length you need to calculate is the input to the function.

Return Value

The function returns the length of the string by counting the characters. Also, it ignores whether characters are a single byte or multibyte. Therefore, the function will return 3 for a string containing three 2-byte characters.

MySQL Character_length function


For instance, consider a simple case of calculating the length of a string.

mysql> SELECT CHARACTER_LENGTH ("Test String");
| CHARACTER_LENGTH ("Test String") |
|                          11 |

In the above example, the string contains 11 characters. The function returns the count of characters in the string.

You can read more detailed examples on MySQL CHAR_LENGTH Function.


In this article, we discussed the MySQL CHARACTER_LENGTH Function. You can read more about it on the Official MySQL Documentation. Additionally, you can learn more about MySQL String Functions on Concatly.

Spread the Knowledge

Leave a Reply

Your email address will not be published. Required fields are marked *