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
-- Starts with prefix
f1 := STARTS_WITH('Hello World', 'Hello'),
-- Case-sensitive
f2 := STARTS_WITH('Hello World', 'hello'),
-- Middle of string
f3 := STARTS_WITH('Hello World', 'World'),
-- Exact match
f4 := STARTS_WITH('test', 'test'),
-- Prefix longer than string
f5 := STARTS_WITH('test', 'testing'),
-- Unicode prefix
f6 := STARTS_WITH('€100', '€'),
-- Empty prefix matches
f7 := STARTS_WITH('abc', ''),
-- NULL yields NULL
f8 := STARTS_WITH(NULL(VARCHAR), 'x')
;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