Skip to content

CHAR_LENGTH

  • str: This is the string for which the character length will be returned. CHAR_LENGTH(str) function returns the length of the given string argument as it would be if converted to a string type. It counts the number of characters, not bytes, so it effectively returns the number of characters in a string, taking into account the multibyte characters.
SELECT CHAR_LENGTH('SQL Documentation');
11

The CHAR_LENGTH() function in MySQL returns the length of a string, in this case ‘SQL Documentation’, as a numeric value. This example returns 11, because there are 11 characters in ‘SQL Documentation’.