Query special characters

Source: Internet
Author: User
Tags sql using
How to filter out the rows that there is a single quote in the content of a field? Or pencent sign? How to select a record with single quotes or percent signs in a field to query special characters (for example, %) in SQL using the escape-defined Escape Character for fuzzy query using the like keyword, when "%", "_", and "[]" appear separately, they are considered as wildcards. To check whether there are percent (%), underscore (_), or square brackets ([]) characters in a column of the character data type, you need to tell the DBMS, consider the characters in the like criterion as actual values rather than wildcards. The keyword escape allows you to determine an escape character, telling DBMS that the character following the escape character is considered as the actual value. The following expression: Like '% m %' escape 'M' defines the Escape Character "M" using the escape keyword ", tells DBMS to use the Second Percentile (%) in the search string "% m %" as the actual value, rather than the wildcard. Of course, the first percentile (%) is still considered as a wildcard, so the strings that meet this query condition are all strings ending with %. Before passing in the content entered by the user as a parameter value, escape the wildcard character (escape). That is to say, if the query condition entered by the user contains a wildcard character, these characters must be treated as data rather than wildcards.

In the personalmember table, find the record containing "[" in the strloginname field.
The following statements are available:
Select strloginname, * From personalmember where strloginname like '% \ [% 'escape '\'

Use the escape keyword to define the escape character. In mode, when an escape character is placed before a wildcard, the wildcard is interpreted as a common character. For example, to search for strings containing string 5% at any position, use:
Where Columna like '% 5/%' escape '/'

Query special characters

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.