|
|
The LIKE Predicate
A LIKE predicate compares the value in a string expression with a character string pattern which may contain wildcard characters (meta-characters).
The string-value on the left hand side of the LIKE operator must be a string expression.
The character-pattern on the right hand side of the LIKE operator is a string expression that can be specified as a string literal or by using a host variable.
The following meta-characters (wildcards) may be used in the character-pattern:
_ stands for any single character
% stands for any sequence of zero or more characters.
Note: Wildcard characters are only used as such in LIKE predicates. In any other context, the characters _ and % have their exact values.
The optional escape character is used to allow matching of the special characters _ and %. When the escape character prefixes _ and %, they are interpreted without any special meaning.
The character-value must be a string expression of length 1. To search for the escape character itself it must appear twice in immediate succession.
An escape character used in a pattern string may only be followed by another escape character or one of the wildcard characters, unless it is itself escaped (i.e. preceded by an escape character).
Examples:
LIKE predicate
Matches
LIKE '%A%' any string containing an uppercase A LIKE '%A\%\\' ESCAPE '\' any string ending with A%\ LIKE '_ABC' any 4-character string ending in ABCA LIKE predicate where the pattern string does not contain any wildcard characters is essentially equivalent to a basic predicate using the "=" operator.
The comparison strings in the LIKE predicate are not conceptually padded with blanks, in contrast to the basic comparison.
'SKYLINE ' = 'SKYLINE' is true
'SKYLINE ' LIKE 'SKYLINE ' is true
|
Upright Database Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 dbtechnology@upright.se |
|
|