' [] ' wildcard character

Source: Internet
Author: User

6.5.4 "[]" wildcard characters

The [] wildcard character is used to specify a series of characters, and a string that satisfies one of these characters and where the position appears in the "[]" wildcard character satisfies the query condition.

Of course, a variety of wildcard characters can also be used in combination. When using a variety of wildcard characters, be sure to clarify the matching criteria for their representations. such as "like ' 5[%]", where "%" within the "[]" wildcard is not understood as "%" wildcard character, but only for "%" characters. For the reader to understand, table 6-5 lists several query conditions and their matching criteria.

Table 6-5 combined wildcard characters and their matching criteria

Query criteria

Matching Criteria

Like ' 5[%] '

5%

Like ' [_]n '

_n

Like ' [A-CDF] '

A,b, c,d or F

Like ' [-ACDF] '

-, A, C, D or F

Like ' [[] '

[

Like '] '

]

Like ' abc[_]d% '

Abc_d or Abc_d ...

Like ' abc[def] '

ABCD, ABCE, or ABCF

Instance 21 uses the ' [] ' wildcard character to query all courses that start with the "meter" or "live" character

In the course table, query for all course names (CNAME), Numbers (scount), and Exam time (ctest) information for all courses beginning with the "Count" or "live" character. Instance code:

SELECT CNAME, Scount, ctest from
COURSE
WHERE CNAME like ' [IPPF]% ' ORDER by
CNAME

The results of the operation are shown in Figure 6.24.

Figure 6.24 All course names that start with "count" or "live"

The character "^", which is listed in the "[]" wildcard, denotes a negative meaning.

Instance 22 uses the "[]" wildcard character to query for all course names that do not start with the "count" or "live" character

Query the course table for all course names (CNAME), Numbers (scount), and Exam time (ctest) information that do not begin with the "count" or "live" character. Instance code:

SELECT CNAME, Scount, ctest from
COURSE
WHERE CNAME like ' [^ IPPF]% ' ORDER by
CNAME

The results of the operation are shown in Figure 6.25.

Figure 6.25 Any course name that does not start with the "count" or "live" word

Of course, the not operator can also get the same result, at which point the SQL code is as follows.

SELECT CNAME, Scount, ctest from
COURSE
WHERE isn't CNAME like ' [IPPF]% ' ORDER by
CNAME

The results of the operation are shown in Figure 6.26.

Figure 6.26 Any course name that does not start with the "count" or "live" word

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.