0
0
MySQLquery~10 mins

LIKE pattern matching in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to find all names starting with 'A'.

MySQL
SELECT * FROM users WHERE name LIKE '[1]';
Drag options to blanks, or click blank then click option'
AA%
B%A%
C_A%
D%A
Attempts:
3 left
💡 Hint
Common Mistakes
Using '%A' which matches names ending with 'A' instead of starting.
Using '%A%' which matches names containing 'A' anywhere.
2fill in blank
medium

Complete the code to find all emails ending with '.com'.

MySQL
SELECT email FROM contacts WHERE email LIKE '[1]';
Drag options to blanks, or click blank then click option'
Acom%
B_.com
C%com%
D%.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'com%' which matches strings starting with 'com'.
Using '%com%' which matches strings containing 'com' anywhere.
3fill in blank
hard

Fix the error in the code to find names with exactly 5 characters.

MySQL
SELECT name FROM employees WHERE name LIKE '[1]';
Drag options to blanks, or click blank then click option'
A____
B_____
C_____%
D%____%
Attempts:
3 left
💡 Hint
Common Mistakes
Using '_____' with a percent sign which matches names with at least 5 characters.
Using four underscores which matches names with 4 characters.
4fill in blank
hard

Fill both blanks to find products with names containing 'pro' anywhere.

MySQL
SELECT * FROM products WHERE product_name LIKE '[1]' OR product_name LIKE '[2]';
Drag options to blanks, or click blank then click option'
A%pro%
Bpro%
C%pro
D_pro_
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pro%' which matches strings starting with 'pro' only.
Using '%pro' which matches strings ending with 'pro' only.
5fill in blank
hard

Fill all three blanks to find users whose username starts with 'a', ends with 'z', and has exactly 5 characters.

MySQL
SELECT username FROM users WHERE username LIKE '[1]' AND username LIKE '[2]' AND username LIKE '[3]';
Drag options to blanks, or click blank then click option'
Aa____
B____z
C_____
Da%z
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'a%z' which allows any length between 'a' and 'z'.
Using patterns with percent signs (%) that do not enforce exact length.