SQL LIKE & Wildcards

Search for patterns in text.

✍️ 3 exercises + code challenge in this lesson

The LIKE operator searches for a pattern in a column using wildcards:

  • %: any number of characters (including none).
  • _: exactly one character.

Examples

  • 'A%': starts with A
  • '%shop': ends with "shop"
  • '%tech%': contains "tech"
  • '_a%': second letter is "a"

In SQLite and MySQL, LIKE is case-insensitive for English letters.

Key Takeaways: SQL LIKE & Wildcards

Mastering SQL LIKE & Wildcards helps you write clean and reliable SQL code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

SQL LIKE & Wildcards Code Example

SQL
SELECT CustomerName FROM Customers WHERE CustomerName LIKE 'A%';

SELECT CustomerName FROM Customers WHERE CustomerName LIKE '%tech%';

SELECT City FROM Customers WHERE City LIKE '_a%';
Free sign-in required · Google login available

SQL LIKE & Wildcards Practice Exercises

Check what you learned in “SQL LIKE & Wildcards”.

/ 3 solved
Fill in the blank

Find names that start with "S".

WHERE CustomerName LIKE ''
✓ Correct! Not quite. Try again.
Multiple choice

Which wildcard matches exactly one character?

✓ Correct! Not quite. Try again.
Code challenge

Select CustomerName of customers whose name contains 'Mart' or 'Books'.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services