Jump to: navigation, search

Mysql LENGTH

From w3cyberlearnings

Contents

MySQL LENGTH Function

This function returns the length of a given string in bytes. CHAR_LENGTH is meansure in characters.

Syntax LENGTH

  • STR: A given string.
LENGTH(STR);

Example 1

mysql> SELECT LENGTH('go');
+--------------+
| LENGTH('go') |
+--------------+
|            2 |
+--------------+
1 row in set (0.00 sec)

Example 2

mysql> SELECT LENGTH('go gl');
+-----------------+
| LENGTH('go gl') |
+-----------------+
|               5 |
+-----------------+
1 row in set (0.00 sec)

Example 3

mysql> select length(_utf8 '?'), char_length(_utf8 '?');
+--------------------+-------------------------+
| length(_utf8 '?') | char_length(_utf8 '?') |
+--------------------+-------------------------+
|                  2 |                       1 |
+--------------------+-------------------------+
1 row in set (0.00 sec)

Related Links


Navigation
Web
SQL
MISC
References