Previous usage of writing like predicates ignored

Source: Internet
Author: User
We know that SELECT statements are used when writing queries using SQL statements. Its basic structure is as follows:
SELECT ... From ... WHERE ... Order by .....
When we use the WHERE Condition clause we know that we can make a fuzzy query from the LIKE keyword, and we know that we can do this using a wildcard character. We usually know the wildcard characters are underlined _ and percent percent. In fact, we have other query matching available, but we do not often use and ignore them. What we are ignoring is matching a specific range [] and matching a specific range of [^] two.
Let's take a look at the wildcard characters defined in Microsoft SQL Server:
Wildcard description

_ (underline) matches any single character

% matches a string that contains one or more characters

[] matches any single character in a particular range (for example, [a-f]) or in a specific set (for example, [abcdef]).

[^] matches any single character that is outside a specific range (for example, [^a-f]) or a particular set (for example, [^abcdef]).

Here's a list of examples to illustrate the use of these wildcard characters.

WHERE FirstName like ' _im ' can find all three-letter, im-terminated names (for example, Jim, Tim).
 


WHERE LastName like '%stein ' can find all employees whose last name ends with Stein.
 


where LastName like '%stein% ' can find all employees in the last name anywhere including Stein.
 


WHERE FirstName like ' [Jt]im ' can find three-letter names that end with IM and start with J or T (that is, Jim and Tim only)


WHERE LastName like ' m[^c]% ' can find all last names starting with M, and the following (second) letter is not C.
 


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.