What is the usage of the SQL INSTR function?
The SQL INSTR function is used to find the position of the first occurrence of a substring within a string.
The syntax of the function is as follows:
INSTR(string, substring, start, occurrence)
- “string is the string that needs to be searched.”
- A substring is a smaller string that is searched for within a larger string.
- The “start” parameter is optional and represents the starting point for the search, with a default value of 1.
- ‘occurrence’ is an optional parameter that indicates the position of the substring to return within the string, with the default value being 1.
The function returns the position of the first occurrence of a substring in a string, or 0 if the substring is not found.