# Recommended: "Mysql method to find the data length: 1. Use the "LENGTH" function to get the string length, with syntax such as "SELECT LENGTH('Character')"; 2. Check the string length through the "CHAR_LENGTH" function, The syntax is "SELECT CHAR_LENGTH('character')".
mysql video tutorial》
MySql calculates the length of the field
User accounts have Chinese characters, find all accounts containing Chinese charactersSELECT member_name FROM table_member WHERE length(member_name)!=char_length(member_name)
LENGTH: A Chinese character counts as three characters, and a number or letter counts as one character.
CHAR_LENGTH: Whether it is Chinese characters, numbers or letters, it is considered a character
SELECT LENGTH('字符'); 输出:6 SELECT CHAR_LENGTH('字符'); 输出:2Characters
SELECT LENGTH('abc'); 输出:3 SELECT CHAR_LENGTH('abc'); 输出:3
Unit | A Chinese character | A number or letter | Example | |
---|---|---|---|---|
char_length
| Character1 | 1 | char_length(str)
|
|
length
| Byte3 | 1 | length(str)
|
|
bit |
24 | 8 | length(str) |
|
max_allowed_packet generally defaults to 4MB (1MB for 5.6.5 and below)
The above is the detailed content of How to find the length of data in mysql. For more information, please follow other related articles on the PHP Chinese website!