0
0
MySQLquery~10 mins

SUBSTRING and LEFT/RIGHT 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 extract the first 3 characters from the column 'name'.

MySQL
SELECT [1](name, 3) AS first_three FROM users;
Drag options to blanks, or click blank then click option'
ALEFT
BRIGHT
CSUBSTRING
DMID
Attempts:
3 left
💡 Hint
Common Mistakes
Using RIGHT instead of LEFT extracts characters from the end.
Using SUBSTRING without specifying the start position correctly.
2fill in blank
medium

Complete the code to extract 4 characters starting from the 2nd character in 'description'.

MySQL
SELECT [1](description, 2, 4) AS part_desc FROM products;
Drag options to blanks, or click blank then click option'
AMID
BLEFT
CSUBSTRING
DRIGHT
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT or RIGHT which do not allow specifying start position.
Confusing the order of parameters.
3fill in blank
hard

Fix the error in the code to get the last 5 characters of 'filename'.

MySQL
SELECT [1](filename, 5) AS last_five FROM files;
Drag options to blanks, or click blank then click option'
ARIGHT
BSUBSTRING
CLEFT
DMID
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT extracts from the start, not the end.
Using SUBSTRING without calculating start position for the end.
4fill in blank
hard

Fill both blanks to extract 3 characters starting from the 4th character of 'address'.

MySQL
SELECT [1](address, [2], 3) AS part_address FROM locations;
Drag options to blanks, or click blank then click option'
ASUBSTRING
BLEFT
C4
DRIGHT
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT or RIGHT which do not take start position.
Using wrong start position number.
5fill in blank
hard

Fill both blanks to extract the first 2 characters of 'code' in uppercase.

MySQL
SELECT UPPER([1](code, [2])) AS code_start FROM codes;
Drag options to blanks, or click blank then click option'
ALEFT
B2
CSUBSTRING
DRIGHT
Attempts:
3 left
💡 Hint
Common Mistakes
Using RIGHT extracts from end, not start.
Using SUBSTRING without correct parameters.