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 ...
Get Practical SQL Handbook, The: Using SQL Variants, Fourth 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.