CHARACTER_LENGTH
CHARACTER_LENGTH(expression)
Section titled “CHARACTER_LENGTH(expression)”- expression: The string argument for which the length will be calculated. This can be a constant, variable, or column of either character or binary data type. The function will return the number of characters in the expression.
Example
Section titled “Example”SELECT CHARACTER_LENGTH('Hello World') AS Length;Output
Section titled “Output”+--------+| Length |+--------+| 11 |+--------+Explanation
Section titled “Explanation”The CHARACTER_LENGTH string function in MySQL returns the length of the specified string character. In the provided example, it returns the length of the string ‘Hello World’ which is 11.
CHARACTER_LENGTH(text) RETURNS integer
Section titled “CHARACTER_LENGTH(text) RETURNS integer”- text: The input string for which the function will return the number of characters. The input can be of type `CHAR`, `VARCHAR`, or `TEXT`.
- returns integer: This indicates that the function will return an integer. Specifically, it returns the character length or number of characters in the specified string.
Example
Section titled “Example”SELECT CHARACTER_LENGTH('PostgreSQL');Output
Section titled “Output”11Explanation
Section titled “Explanation”The CHARACTER_LENGTH function returns the number of characters in the given string ‘PostgreSQL’, in this case, it returns 11.
CHARACTER_LENGTH( string )
Section titled “CHARACTER_LENGTH( string )”- string: This is the input parameter where a string of characters is entered. CHARACTER_LENGTH function will return the number of characters in this supplied string.
Example
Section titled “Example”SELECT CHARACTER_LENGTH('Hello world') AS Length;Output
Section titled “Output”Length11Explanation
Section titled “Explanation”The CHARACTER_LENGTH function is a string function that returns the number of characters in a string. In this example, the function returned 11 as the length of the string ‘Hello world’.
CHARACTER_LENGTH(expression)
Section titled “CHARACTER_LENGTH(expression)”- expression: The string value or the column name of which the character length is to be calculated. Its data type must be CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The function will return the length of the provided string.
Example
Section titled “Example”SELECT CHARACTER_LENGTH('Hello World') FROM dual;Output
Section titled “Output”11Explanation
Section titled “Explanation”In this example, the CHARACTER_LENGTH function was used to calculate the length of the string 'Hello World'. The space in between Hello and World is considered one character, making the total length of the string 11 characters long.