On escaping _mysql of wildcard characters in Mysql fuzzy query

Source: Internet
Author: User

SQL often use like for fuzzy query, and fuzzy query will use the hundred semicolon "%", underline "_" These wildcard characters, where "%" matches any number of characters, "_" match a single character. If we want to blur the query with wildcard strings, such as "60%", "user_name", you need to escape the wildcard character, there are two ways. As follows:

1. The backslash is an escape character, and the backslash is used to escape the% so that it is no longer a wildcard character. The first% here is a wildcard and the second% is not a wildcard character.

Select percent from score where percent like '%0\% ';

2, this is escaped by the Escape keyword, the character after the specific symbol to escape, where the% after the slash is no longer wildcard characters, before the% of the backslash still play wildcard role.

Select percent from score where percent like '%0/% ' escape '/';

The above is a small series for everyone to talk about the MySQL fuzzy query of the wildcard in the escape of all the content, I hope that we support cloud Habitat Community ~

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.