The LIKE predicate retrieves rows where the string value of a column matches a specified pattern. The pattern can contain one or more wildcard characters, which match all valid characters. ILIKE is equivalent to LIKE except that the match is case-insensitive (non-standard extension).
Syntax
string { LIKE | ILIKE } pattern [ESCAPE escape-character]
string NOT { LIKE | ILIKE } pattern [ESCAPE escape-character]
Semantics
string |
(CHAR or VARCHAR) is the column value to be compared to the pattern. |
NOT |
returns true if LIKE returns false, and vice versa (equivalent to |
pattern |
specifies a string containing wildcard characters.
|
ESCAPE |
specifies an escape-character. A null escape character ('') disables the escape mechanism. To match the escape character itself, use two consecutive escape characters. |
escape-character |
when preceding an underscore or percent sign character in the pattern, causes that character to be treated as a literal rather than a wildcard. The default escape character is the backslash (/) character. |
Notes
~~ |
LIKE |
~~* |
ILIKE |
!~~ |
NOT LIKE |
!~~* |
NOT ILIKE |
Examples
'abc' LIKE 'abc' true
'abc' LIKE 'a%' true
'abc' LIKE '_b_' true
'abc' LIKE 'c' false