State the output of the following query:
SELECT MID('PYTON PROGRAMS',4,5);
State the output of the following query:
SELECT MID('PYTON PROGRAMS',4,5);
Solution
✅ Correct Option: 2
MID(string, position, length) returns length characters starting from position, where counting starts at 1.
| P | Y | T | O | N | (space) | P | R | O |
|---|---|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Starting at position 4 and taking 5 characters gives O, N, space, P, R, which is ON PR.
SQL positions start at 1, not 0, so starting from 0 would wrongly give N PRO.
Related questions:
2025: 21 May Shift 1
2026: 23 May Shift 2
2026: 24 May Shift 1
2026: 23 May Shift 2