Server
Author:david Euler
Date:2004/11/17
email:de_euler-david@yahoo.com.cn
Have any questions, please contact me:
SQL Server Books Online searches for like and finds several wildcard characters containing%,_,[],[^.
such as: SELECT * from Mybbs where Content like ' [w]% '
The LIKE keyword is used to search for a string that matches a pattern, or a date or time value.
The sections in SQL Server books are explained as follows:
Pattern Matching in Search Conditions
The LIKE keyword uses a regular expression to contain "the pattern" are matched. The pattern contains the character string to search for, which can contain any combination of four.
Wildcardmeaning%any string of zero or more characters._any single character. []any single character within the specified range (for example, [a-f]) or set (for example, [abcdef]). [^] Any single character not within the specified range (for example, [^a-f]) or set (for example, [^abcdef]).
Enclose the wildcard (s) and the character string in single quotation marks for example:like '%en% ' searches to all stri NGS that contain the letters EN anywhere in the string (Bennet, Green, McBadden).
Like ' _heryl ' searches to all six-letter names ending with the letters Heryl (Cheryl, Sheryl).
Like ' [ck]ars[eo]n ' searches for Carsen, Karsen, Carson, and Karson (Carson).
Like ' [M-z]inger ' searches to all names ending with the letters Inger this begin with the ' I ' M through Z (Ringer).
Like ' m[^c]% ' searches to all names beginning with the letter M ' does not have the letter C as the second letter (Macfe Ather).
This query finds all phone numbers in the authors table, have area code 415:
SELECT phonefrom Pubs.dbo.authorsWHERE phone like ' 415% '
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.