0Pricing
SQL Interview Prep · Lesson

LIKE, Wildcards and Escaping

Pattern matching, percent vs underscore, and escaping literal wildcard characters.

Pattern Matching Under Interview Scrutiny

LIKE looks simple but hides three classic interview gotchas: confusing % with _, forgetting that a literal percent or underscore in the data needs escaping, and the case-sensitivity surprise that differs by database.

This lesson drills the two wildcards, the ESCAPE clause, and the cross-dialect rules an interviewer will probe to separate juniors from people who have shipped real search features.

The Two Wildcards

LIKE has exactly two wildcard characters:

  • % matches zero or more characters
  • _ matches exactly one character

So 'a%' matches anything starting with a, while 'a_' matches a two-character string starting with a. Mixing these up is the number one LIKE mistake.

SELECT *
FROM customers
WHERE name LIKE 'A%';
-- every name beginning with A

All lessons in this course

  1. AND/OR Precedence and Parenthesization
  2. BETWEEN, IN, and Inclusive Boundaries
  3. LIKE, Wildcards and Escaping
  4. Filtering on Calculated Values
← Back to SQL Interview Prep