The SQL statement SELECT SUBSTR('123456789', INSTR('abcabcabc', 'b'), 4) FROM…

2023

The SQL statement

SELECT SUBSTR('123456789', INSTR('abcabcabc', 'b'), 4) FROM DUAL;

  1. A.

    6789

  2. B.

    2345

  3. C.

    1234

  4. D.

    456789

Attempted by 594 students.

Show answer & explanation

Correct answer: B

Answer: Option B

Solution:

INSTR Function:- The INSTR function in SQL is used to find the starting location of a pattern in a string. The syntax for the INSTR function is as follows:

INSTR (str, pattern): Find the starting location of pattern in string str.

SUBSTR Function:- The Substring function in SQL is used to grab a portion of the stored data. The syntax for the SUBSTR function is as follows:

SUBSTR(str,pos,len): Starting with the position pos in string str select the characters upto the length len.

In the above query,

INSTR('abcabcabc', 'b') outputs 2 as the starting location of pattern

Explore the full course: Amcat Preparation