12.6. SIMILAR TO Predicates

As you can see, the LIKE predicate is pretty weak, especially if you have used a version of grep(), a utility program from the UNIX operating system. The name is short for “general regular expression parser,” and before you ask, a regular expression is a class of formal languages. If you are a computer science major, you have seen them; otherwise, don’t worry about it. The bad news is that there are several versions of grep() in the UNIX community, such as egrep(), fgrep(), xgrep(), and a dozen or so others.

The SQL-99 standard added a regular expression predicate of the form <string expression> SIMILAR TO <pattern>, which is based on the POSIX version of grep() found in ISO/IEC 9945.

The special symbols in a pattern ...

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