MySQL LENGTH() Function

The LENGTH() function returns the length of a string.

  • In SQLite (and TechKubo), it returns the number of characters.
  • In MySQL, it returns the number of bytes.

Tutorials dojo strip

MySQL LENGTH Function Syntax

SQL

MySQL LENGTH Function Example

This query returns the length in bytes of the string “SQL Tutorial”:

SQL

MySQL LENGTH Function Parameters

ParameterDescription
stringRequired. The string to measure length

MySQL LENGTH Function Patients Table Example

This query returns the length in bytes of each first_name in the Patients table:

SQL

MySQL LENGTH Function Notes

  • In MySQL: returns length in bytes.
  • In SQLite (TechKubo): returns length in characters.
  • Available from MySQL 4.0 and supported in SQLite.

Tutorials dojo strip
Tutorials dojo strip