Analysis of MySQL string functions

Source: Internet
Author: User

1. left function, used to intercept the string content of the query field. select left (content, 50) as summary from article; here, it means to query only the first 50 characters of the content column. Here, Chinese characters are also considered as only one character.

2. The right function is the opposite of the left function. It intercepts the content from the back.

3. The upper function processes lowercase letters in the queried content in uppercase. Select upper (title) as title from article;

4. The lower function is the opposite of the upper function. It performs lower-case processing.

5. Use the substr function to crop a string at a specified position. This function is more flexible than left and right. Select substr (content, 10, 50) from article. 50 characters are truncated starting from 10th characters (the first character is 1 and not 0). select substr (content, 10) from article, starting from 10th characters to the end; select substr (content,-20) from article, intercepting 20 characters from the end.

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.