Antipattern: Pattern Matching Predicates

Let’s look at how we can use LIKE and REGEXP predicates for searching from a large collection.

SQL provides pattern-matching predicates for comparing strings, and this is the first solution most programmers use when searching for keywords.

Using pattern matching LIKE predicates

The most widely supported of these is the LIKE predicate. The LIKE predicate supports a wildcard (%) that matches zero or more characters. Using this wildcard before and after a keyword matches any string that contains that word. The first wildcard matches any text preceding the word, and the second wildcard matches any text following the word.

Get hands-on with 1200+ tech skills courses.