STRPOS

All functions > STRING > STRPOS

Returns the position of a substring within a string, optionally finding the N-th occurrence.

Syntax

STRPOS(expr, search, instance)
sql

Arguments

ParameterTypeRequiredDescription
stringVARCHARYesString to search in
substringVARCHARYesSubstring to find
occurrenceBIGINTNoWhich occurrence to find (1 for first, 2 for second, etc.) - optional

Returns

Position of the substring (1-indexed), or 0 if not found

Notes

  • Position is 1-indexed
  • Returns 0 if substring not found
  • If occurrence specified, finds N-th occurrence
  • Case-sensitive search
  • See also: POSITION

Examples

Last update at: 2025/10/13 10:23:46