locate
function
Applies to: Databricks SQL Databricks Runtime
Returns the position of the first occurrence of substr
in str
after position pos
. This function is a synonym for position function.
Syntax
locate(substr, str [, pos] )
Arguments
subtr
: A STRING expression.str
: A STRING expression.pos
: An optional INTEGER expression.
Returns
An INTEGER.
The specified pos
and return value are 1-based.
If pos
is omitted substr
is searched from the beginning of str
.
If pos
is less than 1 the result is 0.
Examples
> SELECT locate('bar', 'abcbarbar');
4
> SELECT locate('bar', 'abcbarbar', 5);
7
Related functions
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for