SQL Basics

Fuzzy Matching: LIKE vs. Equals

Senior Data Analyst
January 9, 2026
6 min read

The Vague Request

Customer support pinged me. *"We're looking for a specific item. The customer says it had 'Ultra' in the name, but they can't remember the full title. Can you find it?"*

If I used `WHERE product_name = 'Ultra'`, I would get zero results. Most products aren't named *just* 'Ultra'; they are 'Ultra Pro Max' or 'The Ultra Desk'. I needed a "Fuzzy" search.

The Quest: The Wildcard Search

While `=` is for exact matches, the `LIKE` operator is for patterns. It works with a special symbol: **%** (The Wildcard).

  • `%` stands for "Zero or more characters of any kind."
  • The Implementation: The Pattern Match

    I used `LIKE` with percentages on both sides to find 'Ultra' anywhere in the name.

    -- Finding any product with 'Ultra' anywhere in its title

    SELECT product_name

    FROM products

    WHERE product_name LIKE '%Ultra%';

    Pattern variations

  • `'A%'`: Starts with A.
  • `'%A'`: Ends with A.
  • `'%Ultra%'`: Contains Ultra anywhere.
  • `'_ltra'`: (The underscore) matches exactly one character (e.g., 'Ultra' but not 'Uultra').
  • The "Oops" Moment

    I once forgot that `LIKE` is often **Case-Sensitive** depending on the database. I searched for `'%ultra%'` and found nothing, because all the titles were capitalized: `'Ultra'`.

    **Pro Tip**: Many databases offer `ILIKE` (In-sensitive LIKE) which ignores capitalization. If yours doesn't, use `LOWER(name) LIKE '%ultra%'`.

    The Victory

    I found 4 products with 'Ultra' in the name. Support identified the right one, and the customer was happy. I realized that a good analyst isn't a robot looking for exact bits—they are a detective looking for traces.

    Your Task for Today

    Use `LIKE` to find all customers whose names start with the letter 'S'. Then, try to find all products that have the word 'Blue' in their description.

    *Day 10: Membership Logic—IN vs. EXISTS.*

    Ready to put your knowledge into practice?

    Join SQL Mastery and learn through interactive exercises.