STARTSWITH (NoSQL query)
APPLIES TO: NoSQL
Returns a boolean value indicating whether the first string expression starts with the second.
Syntax
STARTSWITH(<string_expr_1>, <string_expr_2> [, <bool_expr>])
Arguments
Description | |
---|---|
string_expr_1 |
A string expression. |
string_expr_2 |
A string expression to be compared to the beginning of string_expr_1 . |
bool_expr (Optional) |
Optional value for ignoring case. When set to true , STARTSWITH does a case-insensitive search. When unspecified, this default value is false . |
Return types
Returns a boolean expression.
Examples
The following example checks if the string abc
starts with b
or ab
.
SELECT VALUE {
startsWithWrongPrefix: STARTSWITH("AdventureWorks", "Works"),
startsWithCorrectPrefix: STARTSWITH("AdventureWorks", "Adventure"),
startsWithPrefixWrongCase: STARTSWITH("AdventureWorks", "adventure"),
startsWithPrefixCaseInsensitive: STARTSWITH("AdventureWorks", "adventure", true)
}
[
{
"startsWithWrongPrefix": false,
"startsWithCorrectPrefix": true,
"startsWithPrefixWrongCase": false,
"startsWithPrefixCaseInsensitive": true
}
]
Remarks
- This function performs a precise index scan.