Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

CHAR_LENGTH

Example

Provide the length of the string.

SELECT CHAR_LENGTH(“SQL Tutorial”) AS LengthOfString; 

Definition and Usage

The CHAR_LENGTH() function retrieves the length of a string in characters.

Note: This function is equivalent to the CHARACTER_LENGTH() function.

Syntax

CHAR_LENGTH(string)

Parameter Values

Parameter

Description

string

Mandatory. Specifies the string for which to determine the length.

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Retrieve the length of the text within the “CustomerName” column.

SELECT CHAR_LENGTH(CustomerName) AS LengthOfName
FROM Customers;