STRPOS

All functions > STRING > STRPOS

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

Signatures

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

STRPOS(string: VARCHAR, substring: VARCHAR, [occurrence: BIGINT]) → BIGINT
sql
ParameterTypeRequiredDescription
stringVARCHARYesString to search in
substringVARCHARYesSubstring to find
occurrenceBIGINTNoWhich occurrence to find (1 for first, 2 for second, etc.) - optional

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

FeatureQL
SELECT
    f1 := STRPOS('Hello World', 'World'),  -- Basic search
    f2 := STRPOS('Hello Hello World', 'Hello'),  -- First occurrence
    f3 := STRPOS('test', 'xyz')  -- Not found
;
Result
f1 BIGINTf2 BIGINTf3 BIGINT
710

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19