Text & patterns
Scalar
strpos()
Returns location of first occurrence of search_string in string, counting from 1. Returns 0 if no match found.
Alias of instr()
Arguments & returns
strpos(string, search_string)
Scalar
| Overload link | string | search_string |
Returns |
|---|---|---|---|
| #01 | VARCHAR | VARCHAR |
BIGINT |
Example
Haybarn WASM 1.5.5-rc3 · In your browser
Engine example · Run to view results.
In other engines
BigQueryinstr()
SELECT INSTR('[email protected]', '@')
SELECT STRPOS('[email protected]', '@')
Used in larger rewrites 1
These examples use strpos as one part of a larger SQL translation.
Snowflakecharindex()
SELECT CHARINDEX('sub', 'testsubstring', p)
SELECT CASE WHEN STRPOS(SUBSTRING('testsubstring', CASE WHEN p <= 0 THEN 1 ELSE p END), 'sub') = 0 THEN 0 ELSE STRPOS(SUBSTRING('testsubstring', CASE WHEN p <= 0 THEN 1 ELSE p END), 'sub') + CASE WHEN p <= 0 THEN 1 ELSE p END - 1 END