Categories: String, Binary

STRPOS

Searches for the first occurence of the substring in the given expression and returns the position of where the substring begins. Searching binary values is also supported.

Syntax

STRPOS(expression varchar, substring varchar) → int32

  • expression: The expression to search.
  • substring: The substring to search the expression for.

Examples

SELECT STRPOS('dremio cloud service', 'cloud')
-- 8
SELECT STRPOS(1001111, 00)
-- 2
SELECT STRPOS('dremio cloud service', 'sql')
-- 0

Usage Notes

If the substring is not found, the function returns 0. The data type of both parameters must match; they should both be strings or both binary values.