Skip to main content

STRPOS function

Returns the position of the first occurence of a aubstring in a string. If the substring is not found, STRPOS returns 0. If any of the arguments are NULL then STRPOS will return NULL.

Syntax

STRPOS(string-expression, substring-expression)

Arguments

  • string-expression: The string in which to locate substring

  • substring-expression: The substring to locate in string-expression

Binary expressions are not allowed.

Returns

A BIGINT

Examples

> SELECT STRPOS('hello', 'l');
2

> SELECT STRPOS('hello', 'abc');
0

> SELECT STRPOS('cats are cool, cats are cool', 'cats');
1

> SELECT STRPOS(null, 'abc');
NULL