char_length

Description

Syntax

‘INT char_length (VARCHAR str)’

Returns the length of the string, and the number of characters returned for multi-byte characters. For example, five two-byte width words return a length of 5, only utf8 encoding is support at the current version. character_length is the alias for this function.

example

  1. mysql> select char_length("abc");
  2. +--------------------+
  3. | char_length('abc') |
  4. +--------------------+
  5. | 3 |
  6. +--------------------+
  7. mysql> select char_length("中国");
  8. +------------------- ---+
  9. | char_length('中国') |
  10. +-----------------------+
  11. | 2 |
  12. +-----------------------+

keyword

CHAR_LENGTH, CHARACTER_LENGTH