The length function in mysql is a built-in function used to obtain the string length. The usage example is as follows:
(1) view the length of a string (such as the website)
Select length ('www .phpernote.com ');
(2) query the top 10 articles in the article table (article ).
SELECT id, title FROM article order by length (title) DESC;
(3) Check the list of users whose usernames are less than 6 characters long
SELECT * FROM user where length (username) <6;
In the mysql built-in function, another function for viewing the string length is char_length. The difference between the two functions is:
Length: a Chinese character is counted as three characters, and a number or letter is counted as one character.
Char_length: whether it is a Chinese character, a number, or a letter.
Articles you may be interested in
- MySQL replace function replacement string statement usage
- Mysql having and group by statement usage
- MySQL string truncation Function
- MySQL large data volume quick insert method and statement Performance Optimization
- Convert an Object to a String function code in js
- Call_user_func and call_user_func_array Functions
- Mysql queue for efficient Concurrent Data Reading
- MySQL Data Table for Chinese provinces and municipalities