Mysql length Function

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.