Beginner

370. SQL Wildcards

Understand SQL wildcard characters used for flexible pattern matching.

📘 Lesson 370 of 728 ⏱ 10 min 🎯 Beginner

Wildcards are special pattern characters used with LIKE to represent unknown characters. Common wildcards include % for zero or more characters and _ for exactly one character.

Wildcards make text searches flexible and allow analysts to search for patterns instead of exact values.

Find employee names where the second character is 'a'.

SQL
SELECT
    EmployeeName
FROM Employees
WHERE EmployeeName LIKE '_a%';

Wildcards are useful in customer searches, product-code validation, address matching, and text-based reporting.

  • % represents zero or more characters.
  • _ represents one character.
  • Wildcards are commonly used with LIKE.
  • Wildcard behavior can vary for database-specific pattern features.
  • Wildcard searches should be used carefully on large datasets.
What are common SQL LIKE wildcards?

The common wildcards are % for zero or more characters and _ for one character.

What does _ represent in LIKE?

The underscore generally represents exactly one character.

Have you finished this lesson?

Introduction to SQL – All Lessons