CHAR_LENGTH

2023-07-28 02:55:42  Updated

Syntax

CHAR_LENGTH(str)

Purpose

CHAR_LENGTH() returns the number of characters in the str string.

A multi-byte character is counted as one character. For example, if you enter five two-byte characters, the LENGTH() function returns 10, while the CHAR_LENGTH() function returns 5.

Examples

obclient> SELECT CHAR_LENGTH('CN'), LENGTH('CN'),CHAR_LENGTH('hello');
+-----------------------+------------------+----------------------+
| CHAR_LENGTH('CN')   | LENGTH('CN')   | CHAR_LENGTH('hello') |
+-----------------------+------------------+----------------------+
|                     2 |                6 |                    5 |
+-----------------------+------------------+----------------------+
1 row in set

Contact Us