MySQL checks if a string contains substrings

Source: Internet
Author: User

1. Use Substring_index (Src,target,index) to find the index target from the beginning of SRC. The returned substring is the string from the beginning of the SRC to the num target. Likesubstring_index (' ABSSCDESSFSS ', ' SS ', 1) return ABsubstring_index (' ABSSCDESSFSS ', ' SS ', 2) return ABSSCDEsubstring_index (' ABSSCDESSFSS ', ' TT ', 1) return ABSSCDESSFSSTherefore, check whether the string contains substrings, use Substring_index (' ABSSCDESSFSS ', ' TT ', 1) to see if he returns a substring, is a substring of the description contained, returns the original completed string, the description does not contain. Length (src)-Length (Substring_index (src,target,1)) >0 description contains. 2, the second method, the target is replaced with an empty string, if there is a target, the replacement length must be less than the original lengthLength (src)-Length (replace (Src,target, ')) >0 description contains. further thinking, you can also calculate the length of the string containing several substrings, divided by the length of the target, that is, the number of substrings. Select (Length (src)-Length (replace (Src,target, ')))/length (target);

MySQL checks if a string contains substrings

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.