Returns a boolean indicating whether a string ends with the search string.
INDEX_OF() follows this syntax.
-
source_str
- : The string to be searched.
-
search_str
- : The string to search for within the source string.
-
position
- : Optional. The index from which to begin searching the string. The default position is set to 1.
-
occurrence
- : Optional. If there’s more than one instance of the searched string, you can specify occurrence to choose which instance to return. The default occurrence is set to 1.
The function returns 0 if search_str isn’t found.
Example
This example returns the index of the second occurrence of the letter “e” in the first five cities in the dataset.
SELECT City, INDEX_OF(City, 'e', 1, 2) as "indexValue"
FROM "Superstore"
LIMIT 5;
| City | indexValue |
|---|---|
| Henderson | 5 |
| Henderson | 5 |
| Los Angeles | 10 |
| Fort Lauderdale | 15 |
| Fort Lauderdale | 15 |