Question:

State whether the following statement is True or False:

The INSTR(stringl, string2) function in SQL returns 0 if string2 is not present as a substring in string1.

Show Hint

INSTR() gives the position of the substring, and it gives 0 when the substring is not found.
Updated On: Oct 20, 2026
  • True
  • False
  • Cannot be determined
  • None of the above
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Step 1: Recall what INSTR() does:
INSTR(string1, string2) is a text function in MySQL. It searches for string2 inside string1.
It returns the position (starting from 1) where string2 first appears.

Step 2: Recall the not-found case:
If string2 is not present in string1, the function returns 0.
Position 0 is used because the positions of real characters start from 1.

Step 3: Test with an example:
INSTR('Computer', 'put') returns 4, because 'put' starts at the 4th letter.
INSTR('Computer', 'xyz') returns 0, because 'xyz' does not occur in 'Computer'.

Step 4: Decide on the statement:
The statement says INSTR returns 0 when string2 is not a substring of string1. This is exactly the behaviour shown above. So the statement is True.

Step 5: Why the other options fail:
Option (B) False is wrong, because the statement is correct.
Option (C) is wrong, because the result is fixed and can always be found.
Option (D) is wrong, because option (A) is right.

Final Answer:
The statement is True. This is option (A).
Was this answer helpful?
0
0

Top CBSE CLASS XII Text Date and Math Functions in MySQL Questions

View More Questions