mysql Get string length function (the CHAR_LENGTH)

length: length of the field is calculated characters are considered a three characters, a numeric or alphanumeric character count
the CHAR_LENGTH (str) Returns the value of the length of string str, length, in characters. A multi-byte character counts as a single character. For a two-byte character set contains five, the LENGTH () returns a value of 10, while the CHAR_LENGTH () returns a value of 5.
CHARACTER_LENGTH (str) CHARACTER_LENGTH () is CHAR_LENGTH () synonyms.
BIT_LENGTH (str) Returns the binary length.
For example: a user can find out the list of user names longer than six characters.
SQL
copy the code code is as follows:
the SELECT * the FROM ADMIN the WHERE the LENGTH (username) <. 6

The CHAR_LENGTH (str)
Returns the value of the length of string str, length, in characters. A multi-byte character counts as a single character. For a two-byte character set contains five, the LENGTH () returns a value of 10, while the CHAR_LENGTH () returns a value of 5.
CHARACTER_LENGTH (str)
CHARACTER_LENGTH () is CHAR_LENGTH () synonyms.
BIT_LENGTH (str)
returns the length of the binary.
Simple conclusion, mysql acquired string length has two functions:
length: Returns the number of bytes occupied by a string, the length of a calculated field is counted three characters character, a number or letter count as one character
char_length: returns the number of characters occupied by a string, regardless of numbers or letters or characters are regarded as a character

Released seven original articles · won praise 11 · views 80000 +

Guess you like

Origin blog.csdn.net/dxyzhbb/article/details/104030106