The LIKE predicate performs pattern-matching queries.
Column_Reference [NOT] LIKE 'String_Pattern '
Column_Reference | Specifies the column name (alias). Its data type must be compatible with the format of the String_Pattern specified. | |||||||||||||||||||||||||||||||||||
String_Pattern | Specifies the literal of type Basic String to use as the pattern. You can use any combination of string literals along with the valid wildcard characters shown in the following table:
Note: To use the percent ( % ), underscore ( _ ),and left square bracket ( [ ) as literal characters in a LIKE search pattern rather than as wildcards, surround the characters with square brackets. The right square bracket ( ] ) matches itself unless preceded by a left square bracket. The range character ( - ) matches itself unless it is inside square brackets and preceded and followed by a single character. The following illustrates using wildcards as literals:
|
The following example returns rows consisting of the DocAuthor, DocTitle, and size properties for all files under the virtual roots /contracts and /legal, written by authors whose names are Smith, Smyth, Smythe, and so on, where the comment field of those documents does not contain words starting with "real", such as "realty" or "realtor".
SELECT DocAuthor, DocTitle, size FROM SCOPE('"/contracts", "/legal"') WHERE DocAuthor LIKE 'SM_TH%' AND DocComments NOT LIKE 'REAL%'
The following example returns rows consisting of the DocTitle and size properties for all files under the virtual roots /contracts and /legal, written by authors whose names begin with any characters except "A" through "F".
SELECT DocTitle, size FROM SCOPE('"/contracts", "/legal"') WHERE DocAuthor LIKE '[^a-f]%'