POSITION

All functions > STRING > POSITION

Returns the position of the first occurrence of a substring within a string.

Signatures

Returns: Position of first occurrence (1-indexed), or 0 if not found

POSITION(substring: VARCHAR, string: VARCHAR) → BIGINT
sql
ParameterTypeRequiredDescription
substringVARCHARYesSubstring to search for
stringVARCHARYesString to search in

Notes

  • Position is 1-indexed (first character is position 1)
  • Returns 0 if substring is not found
  • Case-sensitive search
  • See also: STRPOS

Examples

FeatureQL
SELECT
    f1 := POSITION('World' IN 'Hello World'),  -- Found at position 7
    f2 := POSITION('o' IN 'Hello World'),  -- First occurrence only
    f3 := POSITION('xyz' IN 'Hello World'),  -- Not found returns 0
    f4 := POSITION('ABC' IN 'ABCABC')  -- Found at beginning
;
Result
f1 BIGINTf2 BIGINTf3 BIGINTf4 BIGINT
7501

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