STARTS_WITH
Descriptionβ
The STARTS_WITH function checks if a string starts with a specified prefix. Returns true if the string starts with the specified prefix; otherwise returns false.
Syntaxβ
STARTS_WITH(<str>, <prefix>)
Parametersβ
Parameter | Description |
---|---|
<str> | The string to check. Type: VARCHAR |
<prefix> | The prefix string to match. Type: VARCHAR |
Return Valueβ
Returns BOOLEAN type.
Special cases:
- Returns NULL if any argument is NULL
Examplesβ
- Successful match
SELECT starts_with('hello world', 'hello');
+-------------------------------------+
| starts_with('hello world', 'hello') |
+-------------------------------------+
| 1 |
+-------------------------------------+
- Failed match
SELECT starts_with('hello world', 'world');
+-------------------------------------+
| starts_with('hello world', 'world') |
+-------------------------------------+
| 0 |
+-------------------------------------+