Skip to main contentSkip to solution

State the output of the following SQL command.

SELECT MID('COMPUTER SCIENCE',-4);

Solution

✅ Correct Option: 2

NTA's key takes "NO OUTPUT", treating MID(string,pos,n)\text{MID}(string, pos, n) as needing all three arguments (the string, the starting position and the number of characters), while only two are given here.


We believe the answer should be Option 1, since NCERT's own table of string functions says that if nn is not specified, MID returns the substring from position pospos till the end of the string, and in MySQL a negative position counts from the end, so MID('COMPUTER SCIENCE',-4) returns ENCE. However, NTA's final answer key (after all challenges) says Option 2.

Keyboard Shortcuts

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