O'Reilly logo

Practical SQL Handbook, The: Using SQL Variants, Fourth Edition by Sandra L. Emerson, Marcy Darnovsky, Judith S. Bowman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Matching Character Strings: LIKE

Some problems can't be solved with comparisons. Here are a few examples:

  • “His name begins with 'Mc' or 'Mac'—I can't remember the rest.”

  • “We need a list of all the 415 area code phone numbers.”

  • “I forget the name of the book, but it has a mention of exercise in the notes.”

  • “Well, it's Carson, or maybe Karsen—something like that.”

  • “His first name is 'Dirk' or 'Dick.' Four letters, starts with a D and ends with a k.”

In each of these cases, you know a pattern embedded somewhere in a column, and you need to use the pattern to retrieve all or part of the row. The LIKE keyword is designed to solve this problem. You can use it with character fields (and on some systems, with date fields). It doesn't work with numeric fields ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required