Skip to main contentSkip to solution

Which of the following will retrieve the second and third character from the City column in the Customer table?

(A) SELECT MID(City,2,2);

(B) SELECT SUBSTR(City,2,2);

(C) SELECT LEFT(City,2,2);

(D) SELECT SUBSTRING(City,2,2);

Solution

✅ Correct Option: 1

MID(), SUBSTR() and SUBSTRING() all use the form function(string, start, length). With start = 2 and length = 2, each returns the 2nd and 3rd characters. For example, if City is 'Delhi', each returns 'el'.


Option (C): LEFT() takes only two arguments, LEFT(string, n), and returns the first n characters from the start. LEFT(City,2,2) has an extra argument and gives an error.

SQL positions start at 1, not 0, so start = 2 means the second character.

Keyboard Shortcuts

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