Recall & Review
beginner
What does the SQL
LIKE operator do in a WHERE clause?The
LIKE operator is used to search for a specified pattern in a column. It helps filter rows where the column's value matches the pattern.Click to reveal answer
beginner
What wildcard characters are commonly used with
LIKE in SQL?The two main wildcards are:<br>-
% which matches zero or more characters<br>- _ which matches exactly one characterClick to reveal answer
beginner
Write a simple SQL query to find all customers whose name starts with 'A'.
Example query:<br>
SELECT * FROM customers WHERE name LIKE 'A%';<br>This finds all names beginning with 'A'.Click to reveal answer
intermediate
How does
LIKE '%abc%' differ from LIKE 'abc%'?LIKE '%abc%' finds any value containing 'abc' anywhere.<br>LIKE 'abc%' finds values starting with 'abc'.Click to reveal answer
intermediate
Can
LIKE be case sensitive?It depends on the database system and collation settings.<br>For example, in MySQL,
LIKE is case-insensitive by default, but in PostgreSQL it is case-sensitive.Click to reveal answer
Which wildcard matches exactly one character in a SQL
LIKE pattern?✗ Incorrect
The underscore (_) matches exactly one character in a pattern.
What does the pattern
'%book%' match in a LIKE clause?✗ Incorrect
The percent signs (%) before and after 'book' mean it can appear anywhere in the value.
Which SQL query finds rows where the column 'city' starts with 'New'?
✗ Incorrect
The pattern 'New%' matches values starting with 'New'.
If you want to find all rows where a column contains exactly 3 characters, which pattern would you use?
✗ Incorrect
Three underscores (_) mean exactly three characters.
In which case is
LIKE case-sensitive by default?✗ Incorrect
PostgreSQL's
LIKE operator is case-sensitive by default.Explain how the SQL
LIKE operator works with wildcards in a WHERE clause.Think about how you search for words containing or starting with certain letters.
You got /3 concepts.
Describe a scenario where you would use
LIKE '%abc%' versus LIKE 'abc%' in a query.Consider searching for a substring anywhere or only at the beginning.
You got /3 concepts.