0
0
MySQLquery~5 mins

LIKE pattern matching in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the SQL LIKE operator do?
The LIKE operator is used to search for a specified pattern in a column. It helps find rows where the column's value matches the pattern.
Click to reveal answer
beginner
What does the % symbol mean in a LIKE pattern?
The % symbol matches zero or more characters of any kind. For example, 'a%' matches any string starting with 'a'.
Click to reveal answer
beginner
What does the _ (underscore) symbol mean in a LIKE pattern?
The _ symbol matches exactly one character. For example, '_at' matches 'cat', 'bat', but not 'at' or 'chat'.
Click to reveal answer
beginner
How would you write a query to find all names that end with 'son'?
Use: SELECT * FROM table WHERE name LIKE '%son'; This finds all names ending with 'son'.
Click to reveal answer
intermediate
Can LIKE be case sensitive in MySQL?
By default, LIKE is case-insensitive in MySQL for non-binary strings. But it can be case-sensitive if the column uses a binary collation.
Click to reveal answer
Which wildcard matches any number of characters in a LIKE pattern?
A_
B%
C*
D#
What does the pattern '_at' match in a LIKE query?
AAny three-letter string with 'at' as last two letters
BAny string starting with 'at'
CAny string containing 'at' anywhere
DAny string ending with 'at'
How do you find rows where a column starts with 'abc' using LIKE?
ALIKE '_abc'
BLIKE '%abc'
CLIKE 'abc%'
DLIKE 'abc'
Is the LIKE operator case sensitive by default in MySQL?
AYes, always case sensitive
BNo, always case insensitive
COnly for numeric columns
DDepends on the column collation
Which query finds all rows where 'city' contains 'York' anywhere?
AWHERE city LIKE '%York%'
BWHERE city LIKE 'York%'
CWHERE city LIKE '_York'
DWHERE city LIKE 'York'
Explain how the LIKE operator works and how to use % and _ wildcards in pattern matching.
Think about searching for words that start, end, or contain certain letters.
You got /4 concepts.
    Describe how case sensitivity affects LIKE queries in MySQL and how it can be controlled.
    Consider how uppercase and lowercase letters are treated in searches.
    You got /4 concepts.