Lessons › SQL › Chapter 2: Filtering
SQL lesson
LIKE and wildcards
LIKE finds rows where a text value matches a pattern rather than an exact phrase.
Try this lesson free →Example
Searching Retail Product Names with LIKE and Wildcards
SELECT * FROM products
WHERE product_name LIKE 'NovaSport%'| product_id | product_name | category | price |
|---|---|---|---|
| P1001 | NovaSport Running Shoes | Footwear | 89.99 |
| P1002 | NovaSport Yoga Mat | Fitness | 34.5 |
| P1005 | NovaSport Water Bottle | Fitness | 19.99 |
Step by step
- The asterisk symbol means all columns.
SELECT * - FROM tells SQL which table to pull the data from.
SELECT * FROM products - WHERE keeps only the rows that match your condition.
SELECT * FROM products WHERE product_name LIKE 'NovaSport%';
Practice
1. Using customers, find the customers whose full_name starts with 'C'.
SELECT * FROM customers WHERE full_name LIKE 'C%'2. Using customers, find the customers whose email ends with '.com'.
SELECT * FROM customers WHERE email LIKE '%.com'3. Using products, find the products whose brand contains 'Home'.
SELECT * FROM products WHERE brand LIKE '%Home%'4. Using products, find the products whose category starts with 'E'.
SELECT * FROM products WHERE category LIKE 'E%'5. Using employees, find the employees whose role ends with 'Analyst'.
SELECT * FROM employees WHERE role LIKE '%Analyst'Learn it by doing. This lesson is a short hands-on level on Bampaa: see it work, then build and write it yourself, with instant feedback.
Try this lesson free →