MySQL: CHAR LENGTH Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL CHAR Length Function

In this guide, we will explain how to use the MySQL CHAR LENGTH function with syntax and examples.

Description

The MySQL CHAR_LENGTH function returns the length of the specified string (measured in characters).

Syntax

The syntax for the CHAR_LENGTH function in MySQL is:

CHAR_LENGTH( string )

Parameters or Arguments

stringThe string to return the length for.

Note

  • When using the CHAR_LENGTH function, a multi-byte character is counted as a single character.
  • The CHARACTER_LENGTH function is a synonym for the CHAR_LENGTH function.
  • See also the LENGTH function.

Applies To

The CHAR_LENGTH function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let’s look at some MySQL CHAR_LENGTH function examples and explore how to use the CHAR_LENGTH function in MySQL.

For example:

mysql> SELECT CHAR_LENGTH(NULL);
Result: NULL

mysql> SELECT CHAR_LENGTH('');
Result: 0

mysql> SELECT CHAR_LENGTH(' ');
Result: 1

mysql> SELECT CHAR_LENGTH('A d g l o b');
Result: 11

mysql> SELECT CHAR_LENGTH('adglob.in');
Result: 9

Next Topic : Click Here

This Post Has One Comment

Leave a Reply