0
0
MySQLquery~10 mins

Why string manipulation is common in MySQL - Test Your Understanding

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

Complete the code to select the first 5 characters of the name column.

MySQL
SELECT [1](name, 5) FROM employees;
Drag options to blanks, or click blank then click option'
ARIGHT
BCONCAT
CSUBSTRING_INDEX
DLEFT
Attempts:
3 left
💡 Hint
Common Mistakes
Using RIGHT instead of LEFT
Using CONCAT which joins strings
Using SUBSTRING_INDEX incorrectly
2fill in blank
medium

Complete the code to find the position of 'a' in the city column.

MySQL
SELECT [1]('a', city) FROM locations;
Drag options to blanks, or click blank then click option'
ALOCATE
BFIND
CINSTR
DPOSITION
Attempts:
3 left
💡 Hint
Common Mistakes
Using POSITION which is standard SQL but less common in MySQL
Using FIND which is not a MySQL function
3fill in blank
hard

Fix the error in the code to convert the email column to lowercase.

MySQL
SELECT [1](email) FROM users;
Drag options to blanks, or click blank then click option'
ALOWER
BLOWERCASE
CTOLOWER
DUPPER
Attempts:
3 left
💡 Hint
Common Mistakes
Using UPPER which converts to uppercase
Using LOWERCASE or TOLOWER which are not valid MySQL functions
4fill in blank
hard

Fill both blanks to extract the domain from an email address.

MySQL
SELECT SUBSTRING(email, [1], [2]) AS domain FROM users;
Drag options to blanks, or click blank then click option'
ALOCATE('@', email) + 1
BLENGTH(email)
CLOCATE('@', email) - 1
DCHAR_LENGTH(email)
Attempts:
3 left
💡 Hint
Common Mistakes
Using LOCATE('@', email) - 1 which points before '@'
Using LENGTH which is similar but may not handle multibyte characters correctly
5fill in blank
hard

Fill all three blanks to create a query that replaces 'old' with 'new' in the description column and trims spaces.

MySQL
SELECT TRIM([1](description, [2], [3])) AS updated_desc FROM products;
Drag options to blanks, or click blank then click option'
AREPLACE
B'old'
C'new'
DSUBSTRING
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUBSTRING which extracts parts but does not replace
Not trimming spaces after replacement