MySQL CHARACTER_LENGTH() Function

The CHARACTER_LENGTH() function returns the number of characters in a string. It is equal to CHAR_LENGTH().

Tutorials dojo strip

MySQL CHARACTER_LENGTH Function Syntax

SQL

MySQL CHARACTER_LENGTH Function Example

This query returns the number of characters in the string 'SQL Tutorial'.

SQL

Note: The CHARACTER_LENGTH() function is supported in MySQL but not in SQLite. This example does not work in the TechKubo playground.

MySQL CHARACTER_LENGTH Function Parameters

ParameterDescription
stringThe string to count the number of characters. Required.

MySQL CHARACTER_LENGTH Function Table Column Example

This query returns the number of characters in the first_name column for each patient.

SQL

Note: The CHARACTER_LENGTH() function is supported in MySQL but not in SQLite. This example does not work in the TechKubo playground.

MySQL CHARACTER_LENGTH Function Notes

  • The result is the number of characters, not bytes.
  • CHARACTER_LENGTH() is equivalent to CHAR_LENGTH().
  • Works in MySQL 4.0 and higher.

Tutorials dojo strip