SQL Server daily accumulation (ii)

Source: Internet
Author: User

1. The LIKE operator: compares a string expression to a pattern in an SQL expression.

Syntax: expression like ' pattern ', expression is a match field, pattern is a matching string. You can find field values that match the pattern you specify by using the LIKE operator. For pattern, you can specify a full value (for example Like "Smith" ), or you can use wildcards to find values within a range (for example Like "Sm*" ).

The following table shows how you can use like to test expressions for different patterns.


match type
< Strong class= "bterm" >
mode
match
(return )
no match
(return )
Multiple characters A*a or A%a AA, ABa, Abbba Abc
*ab* or%ab% ABC, AABB, Xab Azb, BAC
Special characters A[*]a A*a Aaa
Multiple characters ab* or ab% ABCDEFG, ABC Cab, AAB
Single character A?a or A_a AAA, A3A, ABa Abbba
Single digit A#a a0a, A1A, A2A AAA, A10A
Character Range [A-z] F, P, J 2, &
Outside the range [!a-z] 9, &,% B, a
Non-numeric value [!0-9] A, a, &, ~ 0, 1, 9
Composite values a[!b-m]# An9, Az0, A99 ABC, AJ0

wildcard characters that can be used with the LIKE operator, such as the following table:

pattern the characters in matches in expression
? Or _ (underline) Any single character
Or 0 or more characters
# Any single number (0-9)
[Charlist] Any single character in the charlist.
[!charlist] Any single character that is not in the charlist.

SQL Server daily accumulation (ii)

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.