forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
7.0 KiB
7.0 KiB
find_in_set
This function is used to return the position (stating from 1) of str1 in str2 separated by commas (,).
Syntax
find_in_set(string <str1>, string <str2>)
Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
str1 |
Yes |
STRING |
String to be searched for |
str2 |
Yes |
STRING |
String separated by a comma (,) |
Return Values
The return value is of the BIGINT type.
Example Code
- Search for the position of string ab in string abc,123,ab,c. An example command is as follows:
The value 3 is returned.
select find_in_set('ab', 'abc,123,ab,c');
- Search for the position of string hi in string abc,123,ab,c. An example command is as follows:
The value 0 is returned.
select find_in_set('hi', 'abc,123,ab,c');
- The value of any input parameter is NULL. An example command is as follows:
The value NULL is returned.
select find_in_set(null, 'abc,123,ab,c');
Parent topic: String Functions