19

LIKE and SIMILAR TO Predicates

The LIKE predicate is a simple string pattern-matching test with the syntax:

<like predicate> ::=

  <match value> [NOT] LIKE <pattern>

   [ESCAPE <escape character>]

<match value> ::= <character value expression>

<pattern> ::= <character value expression>

<escape character> ::= <character value expression>

The expression M NOT LIKE P is equivalent to NOT (M LIKE P), which follows the usual syntax pattern in SQL. There are two wildcards allowed in the <pattern> string. They are the ‘%’ and ‘_’ characters. The ‘_’ character represents a single arbitrary character; the ‘%’ character represents an arbitrary substring, possibly of length zero. Notice that there is no way to represent zero or one arbitrary character. ...

Get Joe Celko's SQL for Smarties, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.