What will be output of the following SQL statement?
SELECT MID("CUETEXAM",2,5);
What will be output of the following SQL statement?
SELECT MID("CUETEXAM",2,5);
Solution
✅ Correct Option: 2
MID(string, position, length) starts at the given position, counting from 1, and returns that many characters.
Here it starts at position 2 and takes 5 characters.
| C | U | E | T | E | X | A | M |
|---|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Positions 2 to 6 give UETEX.
Option 4: this comes from counting positions from 0, as in Python. SQL counts from 1.
Options 1 and 3: these return only 4 characters, but the length given is 5.
Related questions:
2026: 11 May Shift 2