Beginner

31. SQL Wildcards

Learn how SQL wildcard characters are used with the LIKE operator to search for text patterns.

📘 Lesson 31 of 728 ⏱ 7 min 🎯 Beginner

SQL wildcards are special characters used with the LIKE operator to represent unknown or variable characters in text. The percent sign (%) represents zero or more characters, while the underscore (_) generally represents exactly one character. Wildcards make it possible to search for text patterns without knowing the complete value.

Business datasets often contain names, addresses, product descriptions, email addresses, and other text values where an exact match is not known. Wildcards allow analysts to search these values flexibly.

If you want to find all employees whose names contain the word 'Raj', you can use a wildcard pattern that allows characters before and after the search text.

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

Wildcards are useful for customer searches, employee searches, product analysis, address searches, email analysis, and data-quality investigations.

  • Wildcards are commonly used with LIKE.
  • % represents zero or more characters.
  • _ generally represents one character.
  • Wildcards allow flexible text searches.
  • Wildcards are useful when the complete value is unknown.
What are SQL wildcards?

SQL wildcards are special characters used with LIKE to search for variable or unknown text patterns.

What is the difference between % and _?

% represents zero or more characters, while _ generally represents one character.

Have you finished this lesson?

Introduction to SQL – All Lessons