0
0
SQLquery~5 mins

WHERE with LIKE pattern matching in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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 character
Click 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?
A_
B*
C%
D#
What does the pattern '%book%' match in a LIKE clause?
AValues containing 'book' anywhere
BValues ending with 'book'
CValues starting with 'book'
DValues exactly equal to 'book'
Which SQL query finds rows where the column 'city' starts with 'New'?
ASELECT * FROM table WHERE city LIKE '%New';
BSELECT * FROM table WHERE city LIKE 'New%';
CSELECT * FROM table WHERE city LIKE '_New%';
DSELECT * FROM table WHERE city LIKE '%New%';
If you want to find all rows where a column contains exactly 3 characters, which pattern would you use?
ALIKE '%'
BLIKE '___%'
CLIKE '___'
DLIKE '_'
In which case is LIKE case-sensitive by default?
AMySQL
BOracle
CSQLite
DPostgreSQL
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.