CHAR_LENGTH

You are viewing an old version of this article. View the current version here.

Syntax

CHAR_LENGTH(str)

Description

Returns the length of the string str, measured in characters. A multi-byte character counts as a single character. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5. If the argument is NULL, returns NULL. If str is not a string value, it is converted into string.

Examples

SELECT CHAR_LENGTH('MariaDB');
+------------------------+
| CHAR_LENGTH('MariaDB') |
+------------------------+
|                      7 |
+------------------------+

SELECT CHAR_LENGTH('π');
+-------------------+
| CHAR_LENGTH('π')  |
+-------------------+
|                 1 |
+-------------------+

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.