Define escape characters using escape

Source: Internet
Author: User

6.5.5 use escape to define escape characters

When you use the LIKE keyword for a fuzzy query, "%", "_" and "[]" are considered wildcard characters when they appear alone. To query for the existence of a percent sign (%), underscore (_), or square brackets ([]) characters in a column of character data types, you need a way to tell the DBMS that these characters in a like sentence are considered to be actual values, not wildcard characters. The keyword escape allows you to determine an escape character that tells the DBMS that the character immediately following the escape character is considered to be the actual value. As in the following expression:

Like '%m% ' ESCAPE ' M '

The escape character "M" is defined using the Escape keyword, telling the DBMS to use the second percentile (%) in the search string "%m%" as the actual value instead of the wildcard character. Of course, the first percentile (%) is still considered a wildcard, so the string that satisfies the query condition is all a string ending in%.

Similarly, the following expression:

Like ' ab&_% ' ESCAPE ' & '

At this point, the escape character "&" is defined, and the character in the search string immediately after "&", that is, "_" as the actual character value, not a wildcard character. The expression "%" is still treated as a wildcard character. The query condition for the expression is all strings that start with "Ab_".

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.