CHARACTER_LENGTH
Description
CHARACTER_LENGTH, used to return the number of characters in a string.
Syntax
CHARACTER_LENGTH(string|char|)
Parameter Description
- string: The string expression whose length is to be calculated.
Return Result
This function returns an integer representing the total number of characters in the input string.
Example
Example 1: Basic Usage
SELECT CHARACTER_LENGTH('Hello, World!');
+-------------------------------------+
| `CHARACTER_LENGTH`('Hello, World!') |
+-------------------------------------+
| 13 |
+-------------------------------------+
Example 2: Using with NULL Values
SELECT CHARACTER_LENGTH(NULL);
+--------------------------+
| `CHARACTER_LENGTH`(NULL) |
+--------------------------+
| null |
+--------------------------+
Example 3: Chinese Characters
SELECT CHARACTER_LENGTH('中文');
+--------------------------+
| `CHARACTER_LENGTH`('中文') |
+--------------------------+
| 2 |
+--------------------------+