This function is used to return the position (stating from 1) of str1 in str2 separated by commas (,).
find_in_set(string <str1>, string <str2>)
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
str1 |
Yes |
STRING |
String to be searched for |
str2 |
Yes |
STRING |
String separated by a comma (,) |
The return value is of the BIGINT type.
The value 3 is returned.
select find_in_set('ab', 'abc,123,ab,c');
The value 0 is returned.
select find_in_set('hi', 'abc,123,ab,c');
The value NULL is returned.
select find_in_set(null, 'abc,123,ab,c');