Book Contents

Book Index

Next Topic

Home

LIKE-predicate

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 NOT string LIKE pattern).

pattern

specifies a string containing wildcard characters.

  • underscore (_) matches any single character.
  • percent sign (%) matches any string of zero or more 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

Examples

'abc' LIKE 'abc' true

'abc' LIKE 'a%' true

'abc' LIKE '_b_' true

'abc' LIKE 'c' false