Recall & Review
beginner
What does the
LIKE operator do in SQL?The
LIKE operator is used to search for a specified pattern in a column. It matches text based on wildcard characters like % for any sequence of characters and _ for a single character.Click to reveal answer
beginner
What is the difference between
LIKE and ILIKE in PostgreSQL?LIKE is case-sensitive, meaning it distinguishes uppercase and lowercase letters. ILIKE is case-insensitive, so it matches letters regardless of case.Click to reveal answer
beginner
What does the wildcard
% represent in a LIKE pattern?The
% wildcard matches zero or more characters of any kind. For example, 'a%' matches any string starting with 'a'.Click to reveal answer
beginner
How do you match exactly one character in a pattern using
LIKE?Use the underscore
_ wildcard to match exactly one character. For example, 'b_t' matches 'bat', 'bit', or 'but'.Click to reveal answer
intermediate
Write a query to find all names starting with 'Jo' ignoring case using
ILIKE.Example query: <br>
SELECT * FROM users WHERE name ILIKE 'Jo%'; <br>This finds names like 'John', 'joanna', or 'JOSEPH'.Click to reveal answer
Which wildcard matches any number of characters in a
LIKE pattern?✗ Incorrect
The percent sign (%) matches zero or more characters in SQL pattern matching.
What does
ILIKE do differently than LIKE in PostgreSQL?✗ Incorrect
ILIKE performs case-insensitive pattern matching.Which pattern matches any single character in
LIKE?✗ Incorrect
The underscore (_) matches exactly one character.
What will
WHERE name LIKE 'A%' return?✗ Incorrect
The pattern 'A%' matches any string starting with 'A'.
Which query finds names like 'Sam', 'sam', or 'SAM'?
✗ Incorrect
ILIKE matches 'Sam' ignoring case.Explain how to use
LIKE and ILIKE for pattern matching in PostgreSQL.Think about how you find words that start with or contain certain letters.
You got /4 concepts.
Describe the difference between the wildcards % and _ in SQL pattern matching.
One wildcard is for many characters, the other for just one.
You got /2 concepts.