0
0
MySQLquery~10 mins

LOCATE and INSTR 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 the position of 'cat' in the string 'concatenate'.

MySQL
SELECT [1]('cat', 'concatenate');
Drag options to blanks, or click blank then click option'
ALOCATE
BINSTR
CFIND
DPOSITION
Attempts:
3 left
💡 Hint
Common Mistakes
Using INSTR with arguments in the wrong order.
Using POSITION which is not supported in MySQL.
2fill in blank
medium

Complete the code to find the position of 'dog' in the string 'hotdogstand'.

MySQL
SELECT [1]('dog', 'hotdogstand');
Drag options to blanks, or click blank then click option'
ALOCATE
BINSTR
CPOSITION
DFIND_IN_SET
Attempts:
3 left
💡 Hint
Common Mistakes
Using FIND_IN_SET which is for comma-separated lists.
Using POSITION which is not standard in MySQL.
3fill in blank
hard

Fix the error in the code to correctly find the position of 'sun' in 'sunshine'.

MySQL
SELECT INSTR('sunshine', [1]);
Drag options to blanks, or click blank then click option'
Asun
B'sun'
C'shine'
Dsunshine
Attempts:
3 left
💡 Hint
Common Mistakes
Not putting the substring in quotes.
Using the full string as the substring.
4fill in blank
hard

Fill both blanks to find the position of 'day' in 'holiday' starting from position 3.

MySQL
SELECT LOCATE([1], [2], 3);
Drag options to blanks, or click blank then click option'
A'day'
B'holiday'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the substring and string arguments.
Not using quotes around strings.
5fill in blank
hard

Fill all three blanks to find the position of 'test' in 'this is a test string' starting from position 11.

MySQL
SELECT LOCATE([1], [2], [3]);
Drag options to blanks, or click blank then click option'
A'test'
B'this is a test string'
C11
D'string'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong start position.
Not quoting strings properly.