What will be the output of the following SQL query?
SELECT LEFT("INDIA",3), RIGHT("COMPUTER SCIENCE",4);
What will be the output of the following SQL query?
SELECT LEFT("INDIA",3), RIGHT("COMPUTER SCIENCE",4);
Solution
✅ Correct Option: 1
LEFT(str, n) returns the first n characters, so LEFT("INDIA", 3) gives IND.
RIGHT(str, n) returns the last n characters, so RIGHT("COMPUTER SCIENCE", 4) gives ENCE.
Joining the two results in order gives INDENCE.
MySQL actually shows them as two separate columns, IND and ENCE.
Option 2: this swaps LEFT and RIGHT, taking the last 3 of INDIA (DIA) and the first 4 of COMPUTER SCIENCE (COMP).
Option 3: the parts are right, but the order is reversed. The query lists LEFT first.
Option 4: this applies LEFT to both strings.
Related questions:
2025: 16 May Shift 1
2026: 29 May Shift 2