0
0
MySQLquery~20 mins

LIKE pattern matching in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
LIKE Pattern Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Find names starting with 'Jo' using LIKE
Given a table users with a column name, which query returns all names starting with 'Jo'?
MySQL
SELECT name FROM users WHERE name LIKE 'Jo%';
ASELECT name FROM users WHERE name LIKE 'Jo%';
BSELECT name FROM users WHERE name LIKE '%Jo';
CSELECT name FROM users WHERE name LIKE '_Jo%';
DSELECT name FROM users WHERE name LIKE 'Jo_'
Attempts:
2 left
💡 Hint
Use % to match any sequence of characters after 'Jo'.
query_result
intermediate
2:00remaining
Match emails ending with '.com'
Which query returns all emails ending with '.com' from the contacts table?
MySQL
SELECT email FROM contacts WHERE email LIKE '%.com';
ASELECT email FROM contacts WHERE email LIKE '%.com';
BSELECT email FROM contacts WHERE email LIKE '%com.';
CSELECT email FROM contacts WHERE email LIKE '.com%';
DSELECT email FROM contacts WHERE email LIKE '%com';
Attempts:
2 left
💡 Hint
Use % before '.com' to match any characters before the ending.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in LIKE pattern
Which option contains a syntax error in the LIKE pattern?
MySQL
SELECT * FROM products WHERE code LIKE 'A_%%';
ASELECT * FROM products WHERE code LIKE 'A_%';
B;'%_A' EKIL edoc EREHW stcudorp MORF * TCELES
CELECT * FROM products WHERE code LIKE 'A_%';
DSELECT * FROM products WHERE code LIKE 'A_%%';
Attempts:
2 left
💡 Hint
Check if the pattern uses valid wildcard characters.
query_result
advanced
2:00remaining
Find rows where name contains 'an' anywhere
Which query returns all rows from employees where the name contains the substring 'an' anywhere?
MySQL
SELECT * FROM employees WHERE name LIKE '%an%';
ASELECT * FROM employees WHERE name LIKE 'an%';
BSELECT * FROM employees WHERE name LIKE '%an%';
CSELECT * FROM employees WHERE name LIKE '_an%';
DSELECT * FROM employees WHERE name LIKE '%an';
Attempts:
2 left
💡 Hint
Use % before and after 'an' to match anywhere in the string.
🧠 Conceptual
expert
3:00remaining
Understanding escape characters in LIKE patterns
You want to find rows where the column code contains the literal underscore character '_'. Which query correctly finds these rows?
ASELECT * FROM table WHERE code LIKE '%[_]%';
BSELECT * FROM table WHERE code LIKE '%_%';
CSELECT * FROM table WHERE code LIKE '%\_%' ESCAPE '\';
DSELECT * FROM table WHERE code LIKE '%\_%';
Attempts:
2 left
💡 Hint
Use ESCAPE clause to treat underscore as a normal character.