The BIT_LENGTH(str) function return the String str length in bits. Here are the some example of the BIT_LENGTH(str) function:
7
For example: ::
6
The BIT_LENGTH(str) function return the String str length in bits. Here are the some example of the BIT_LENGTH(str) function:
7
For example:
8
9
.. code-block:: mysql
8
10
9
11
SELECT BIT_LENGTH('a');
10
12
12
14
13
15
CHAR_LENGTH
14
16
-----------
15
The CHAR_LENGTH(str) function returns string length measured in characters.
16
17
A multi-byte character counts as single character such as a string contains 5 two-byte characters, then LENGTH() function returns 10, but the CHAR_LENGTH() returns 5. ::
18
CHARACTER_LENGTH(str)
19
This function is same as CHAR_LENGTH().
17
The CHAR_LENGTH(str) function returns string length measured in characters.
18
19
A multi-byte character counts as single character such as a string contains 5 two-byte characters, then LENGTH() function returns 10, but the CHAR_LENGTH() returns 5. ::
20
21
CHARACTER_LENGTH(str)
22
23
This function is same as CHAR_LENGTH().
20
24
21
25
22
26
LENGTH()
23
27
--------
24
28
25
The LENGTH function returns the length of the string argument in bytes. A multi-byte character counts as multiple bytes. This means that for a string containing a three-byte character, LENGTH() returns 3, whereas CHAR_LENGTH() returns 1. For example: ::
29
The LENGTH function returns the length of the string argument in bytes. A multi-byte character counts as multiple bytes. This means that for a string containing a three-byte character, LENGTH() returns 3, whereas CHAR_LENGTH() returns 1. For example:
30
31
.. code-block:: mysql
26
32
27
33
select length(_utf8 '€');
28
34
30
36
31
37
The is because the Euro sign is encoded as 0xE282AC in UTF-8 and thereby occupies 3 bytes.