find_in_set
function
Applies to: Databricks SQL Databricks Runtime
Returns the position of a string within a comma-separated list of strings.
Syntax
find_in_set(searchExpr, sourceExpr)
Arguments
searchExpr
: A STRING expression specifying the “word” to be searched.sourceExpr
: A STRING expression with commas separating “words”.
Returns
An INTEGER.
The resulting position is 1-based and points to the first letter of the match.
If no match is found for searchExpr
in sourceExpr
or searchExpr
contains a comma, 0 is returned.
Examples
> SELECT find_in_set('ab','abc,b,ab,c,def');
3
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