String Functions
This section includes functions that operate on string values.
Searching for Position of One String within Another
Which function searches for one string inside another string? The arguments are:
- <search string>: The string to be searched
- <pattern>: The string to look for
- <occurrence>: Which occurrence
- <offset>: Where to start searching
IBM DB2
LOCATE(<pattern>, <search string>, <offset>)
The argument <offset> is optional and defaults to 1. The function returns the position in the search string where the pattern is found and 0 if the pattern is not found.
An alternative method:
POSSTR(<search string>, <pattern>)
The function returns the position in the search string where the pattern is found and 0 if the pattern is not found.
MySQL
INSTR(<search string>, <pattern>)
The function returns the position in the search string where the pattern is found and 0 if the pattern is not found.
An alternative...