LENGTH(str)
and OCTET_LENGTH(str)
functions are used to return the byte length of a string, for example:
1 2 3 4 |
|
In utf8mb4 encoding, one Chinese character occupies 3 bytes.
In addition, the CHAR_LENGTH(str)
and CHARACTER_LENGTH(str)
functions are used to return the character length of the string, which is the number of characters. For example:
1 2 3 4 |
|
BIT_LENGTH(str)
The function is used to return the bit length (number of bits) of a string, for example:
1 2 3 4 |
|
A byte contains 8 bits.
The above is the detailed content of How to use the LENGTH() function in MySQL. For more information, please follow other related articles on the PHP Chinese website!