If a match_set is specified, this position in the search pattern can be replaced by the exact number of characters specified in the match_set.
<match_set> ::= <underscore> | X'1E' | <match_char>
<match_char> ::= Every character other than %, X'1F', underscore, X'1E'
A LIKE predicate is used to search for character strings that have a certain pattern. Match_set can be used to specify the pattern (pattern element).
· <underscore> | X'1E' : this position in the pattern can be replaced by any one character
· match_char : this position in the pattern can be replaced by the specified character itself.
Example table: customer
Finding all customers whose names consist of six letters and begin with 'P':
SELECT name, firstname, city FROM customer
WHERE name LIKE 'P_ _ _ _ _'
NAME |
FIRSTNAME |
CITY |
Porter |
Jenny |
New York |
Porter |
Martin |
Los Angeles |
Peters |
Sally |
Los Angeles |
Porter |
Michael |
New York |
Peters |
Joseph |
Los Angeles |