mysql gets the string length function of CHAR_LENGTH


length: Is to calculate the length of the field. A Chinese character counts as 3 characters, and a number or letter counts as 1 character CHAR_LENGTH(str) returns the length of the string str in characters. A multi-byte character counts as a single character. For a set of five 2-byte character sets, LENGTH() returns a value of 10, while CHAR_LENGTH() returns a value of 5. CHARACTER_LENGTH(str) CHARACTER_LENGTH() is a synonym for CHAR_LENGTH(). BIT_LENGTH(str) returns the base 2 length. For example, you can find a list of users whose username is less than 6 characters long. SQL

SELECT * FROM admin WHERE LENGTH(username) < 6
 

CHAR_LENGTH(str) The return value is the length of the string str, in characters. A multi-byte character counts as a single character. For a set containing five 2-byte character sets, LENGTH() returns a value of 10, while CHAR_LENGTH() returns a value of 5. CHARACTER_LENGTH(str) CHARACTER_LENGTH() is a synonym for CHAR_LENGTH(). BIT_LENGTH(str) Returns the base 2 length. To summarize, there are two functions in mysql that get the length of a string: length: Returns the number of bytes in the string, which is the length of the calculated field. A Chinese character counts as 3 characters, and a number or letter counts as 1 character char_length: Returns the number of characters in a string. Characters, Numbers, or letters are counted as 1 character