

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: AS Clause in SQL
incomplete
2: SQL Functions
incomplete
3: Between
incomplete
4: Distinct
incomplete
5: Logical Operators – AND
incomplete
6: OR
incomplete
7: In
incomplete
8: Like
incomplete
9: Underscore Operator
incomplete
10: Wildcards Quiz
incomplete
11: Query Practice – Discount Program
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Sometimes we don't have the luxury of knowing exactly what it is we need to query. Have you ever wanted to look up a song or a video but you only remember part of the name? SQL offers us an option for when we're in situations LIKE this.
The LIKE keyword allows for the use of the % and _ wildcard operators. Let's focus on % first.
The % operator will match zero or more characters. We can use this operator within our query string to find more than just exact matches, depending on where we place it.
SELECT * FROM products
WHERE product_name LIKE 'banana%';
SELECT * FROM products
WHERE product_name LIKE '%banana';
SELECT * FROM products
WHERE product_name LIKE '%banana%';
Our HR team is dealing with a ticket from one of our users, but they're having trouble pulling up their record in the database. They are pretty sure the user's name starts with Bo.
Write a query that returns all fields for records in the users table where the user's name starts with Bo.
The LIKE operator expects a string value. Make sure the statement you are comparing against is wrapped in quotes, or SQL will think you're referring to a column!