Skip to main contentSkip to solution

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question