STARTS_WITH()

All functions > STRING > STARTS_WITH()

Returns TRUE if a string starts with a specified prefix.

Signatures

Returns: TRUE if string starts with prefix, FALSE otherwise

STARTS_WITH(string: VARCHAR, prefix: VARCHAR) → BOOLEAN
sql
ParameterTypeRequiredDescription
stringVARCHARYesString to check
prefixVARCHARYesPrefix to look for

Notes

  • Case-sensitive comparison
  • Returns FALSE if prefix is longer than string
  • Returns TRUE if string and prefix are identical
  • An empty prefix is contained at the start of every string (including ''); a non-empty prefix never matches ''
  • If either argument is NULL the result is NULL (use NULL(VARCHAR); bare NULL fails inference)

Examples

FeatureQL
SELECT
    f1 := STARTS_WITH('Hello World', 'Hello'), -- Starts with prefix
    f2 := STARTS_WITH('Hello World', 'hello'), -- Case-sensitive
    f3 := STARTS_WITH('Hello World', 'World'), -- Middle of string
    f4 := STARTS_WITH('test', 'test'), -- Exact match
    f5 := STARTS_WITH('test', 'testing'), -- Prefix longer than string
    f6 := STARTS_WITH('€100', '€'), -- Unicode prefix
    f7 := STARTS_WITH('abc', ''), -- Empty prefix matches
    f8 := STARTS_WITH(NULL(VARCHAR), 'x') -- NULL yields NULL
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEANf4 BOOLEANf5 BOOLEANf6 BOOLEANf7 BOOLEANf8 BOOLEAN
truefalsefalsetruefalsetruetrueNULL

Last update at: 2026/05/26 17:22:09