MySQL string Truncation

Source: Internet
Author: User
Tags truncated

MySQL string Truncation

MySQL string Truncation

1. Extract strings from the left
Left (str, length)
Note: left (truncated field, truncated length)
Example: select left (content, 200) as abstract from my_content_t

2. Extract strings from the right
Right (str, length)
Note: right (intercepted field, truncated length)
Example: select right (content, 200) as abstract from my_content_t

3. truncate a string
Substring (str, pos)
Substring (str, pos, length)
Description: substring (truncated field, starting from the nth digit)
Substring (truncated field, starting from the nth digit and intercepting the length)
Example: select substring (content, 5) as abstract from my_content_t
Select substring (content, 5,200) as abstract from my_content_t
(Note: if the number of digits is negative, for example,-5, it is the length from the last to the end or truncation of the string)

4. truncate a string by keyword
Substring_index (str, delim, count)
Note: substring_index (intercepted field, keyword, number of times the keyword appears)

-------------------------------------- Split line --------------------------------------

Install MySQL in Ubuntu 14.04

MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

Build a MySQL Master/Slave server in Ubuntu 14.04

Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS

Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04

MySQL-5.5.38 universal binary Installation

-------------------------------------- Split line --------------------------------------

This article permanently updates the link address:

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.