Chapter 21

LIKE and SIMILAR TO Predicates

Abstract

String matching is done with two built-in functions.

Keywords

ESCAPE

grep()

ISO/IEC 9945

LIKE

Pattern

POSIX

Regular expression

SIMILAR TO

UNIX

UPPER

The LIKE predicate is a 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 wild cards allowed in the < pattern > string. They are the ‘%’ and ‘_’ characters. The ‘_’ character represents ...

Get Joe Celko's SQL for Smarties, 5th 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.