MySQL: LENGTH Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL LENGTH Function

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

Description

The MySQL LENGTH function returns the length of the specified string (measured in bytes).

Syntax

The syntax for the LENGTH function in MySQL is:

LENGTH( string )

Parameters or Arguments

string

The string to return the length for.

Note

  • When using the LENGTH function, a multi-byte character is counted as more than one byte.
  • See also the CHAR_LENGTH function.

Applies To

The 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 LENGTH function examples and explore how to use the LENGTH function in MySQL.

For example:

mysql> SELECT LENGTH(NULL);
Result: NULL

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

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

mysql> SELECT LENGTH('Ad gl o b');
Result: 9

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

Next Topic : Click Here

This Post Has One Comment

Leave a Reply