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.
MySQL LENGTH Function Syntax
SQL
x
1
LENGTH(string)
MySQL LENGTH Function Example
This query returns the length in bytes of the string “SQL Tutorial”:
SQL
1
1
SELECT LENGTH("SQL Tutorial") AS LengthOfString;

MySQL LENGTH Function Parameters
Parameter | Description |
---|---|
string | Required. 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
1
1
SELECT LENGTH(first_name) AS LengthOfName
2
FROM Patients;

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.