IN, BETWEEN, and LIKE
IN checks a set of values
IN is convenient when one value needs to be compared with several allowed options.
SELECT name
FROM products
WHERE category IN ('book', 'course', 'video');
This is shorter and clearer than repeating several comparisons with OR.
BETWEEN checks a range
SELECT name, price
FROM products
WHERE price BETWEEN 1000 AND 3000;
BETWEEN includes both ends of the range. In the example, both 1000 and 3000 are included.
LIKE matches a pattern
SELECT name
FROM users
WHERE name LIKE 'Ann%';
In a pattern, % means a sequence of zero or more characters. So the condition matches strings that start with Ann.
Another common pattern character is _: it matches exactly one character.
Case sensitivity for LIKE depends on the database system and string comparison settings.
Do not automatically assume that
LIKE is case-insensitive. Its behavior must be understood in the context of the specific database.
Check yourself
Exercise review
The mentor knows the solution and will help you reach it independently
Sign in to use the Mentor
The Mentor uses the current exercise and your conversation history.
Sign in
Review the key nuances and the answer after making your own attempt.
Sign in to view the solution
The solution and explanation are available after signing in.
Sign in