ENDS_WITH()
All functions > STRING > ENDS_WITH()
Returns TRUE if a string ends with a specified suffix.
Signatures
Returns: TRUE if string ends with suffix, FALSE otherwise
ENDS_WITH(string: VARCHAR, suffix: VARCHAR) → BOOLEAN sql
| Parameter | Type | Required | Description |
|---|---|---|---|
string | VARCHAR | Yes | String to check |
suffix | VARCHAR | Yes | Suffix to look for |
Notes
- Case-sensitive comparison
- Returns FALSE if suffix is longer than string
- Returns TRUE if string and suffix are identical
- An empty suffix is contained at the end of every string (including
''); a non-empty suffix never matches'' - If either argument is NULL the result is NULL (use
NULL(VARCHAR); bareNULLfails inference)
Examples
FeatureQL
SELECT
-- Ends with suffix
f1 := ENDS_WITH('Hello World', 'World'),
-- Case-sensitive
f2 := ENDS_WITH('Hello World', 'world'),
-- Exact match
f3 := ENDS_WITH('test', 'test'),
-- Suffix longer than string
f4 := ENDS_WITH('ting', 'testing'),
-- Unicode suffix
f5 := ENDS_WITH('100€', '€'),
-- Empty suffix matches
f6 := ENDS_WITH('abc', ''),
-- Non-empty suffix on empty string
f7 := ENDS_WITH('', 'abc'),
-- NULL yields NULL
f8 := ENDS_WITH('x', NULL(VARCHAR))
;Result
| f1 BOOLEAN | f2 BOOLEAN | f3 BOOLEAN | f4 BOOLEAN | f5 BOOLEAN | f6 BOOLEAN | f7 BOOLEAN | f8 BOOLEAN |
|---|---|---|---|---|---|---|---|
| true | false | true | false | true | true | false | NULL |
On this page