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
| Parameter | Type | Required | Description |
|---|---|---|---|
string | VARCHAR | Yes | String to check |
prefix | VARCHAR | Yes | Prefix 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); bareNULLfails 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 BOOLEAN | f2 BOOLEAN | f3 BOOLEAN | f4 BOOLEAN | f5 BOOLEAN | f6 BOOLEAN | f7 BOOLEAN | f8 BOOLEAN |
|---|---|---|---|---|---|---|---|
| true | false | false | true | false | true | true | NULL |
On this page