Analyze the following MySQL query: SELECT RIGHT (LEFT('COMPUTER SCIENCE', 6),…

2026

Analyze the following MySQL query:
SELECT RIGHT (LEFT('COMPUTER SCIENCE', 6), 3);
Which of the following queries will produce the same output as the one shown above?

  1. A.

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

  2. B.

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

  3. C.

    SELECT INSTR('COMPUTER SCIENCE', 4, 3);

  4. D.

    SELECT INSTR('COMPUTER SCIENCE', 3, 4);

Attempted by 311 students.

Show answer & explanation

Correct answer: B

First evaluate the given query step by step:

SELECT RIGHT(LEFT('COMPUTER SCIENCE', 6), 3);

Step 1: LEFT('COMPUTER SCIENCE', 6) → takes first 6 characters
Result → "COMPUT"

Step 2: RIGHT("COMPUT", 3) → takes last 3 characters
Result → "PUT"

So, final output is: "PUT"

Now check equivalent query using MID():
MID(string, start, length)

"PUT" starts from position 4 and has length 3 in "COMPUTER SCIENCE"

So the equivalent query is:
SELECT MID('COMPUTER SCIENCE', 4, 3);

Correct answer: Option B

Explore the full course: Up Lt Grade Assistant Teacher 2025