find_in_set
The find_in_set function is used to find the position of string str1 in the comma (,) separated string str2, counting from 1.
Syntax
find_in_set(string , string )
Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| str1 | Yes | STRING | The string to find. |
| str2 | Yes | STRING | A string separated by commas (`,`). |
Return Values
Returns a value of type BIGINT.
- When str1 cannot be matched in str2 or str1 contains a comma (,), 0 is returned.
- When str1 or str2 is NULL, NULL is returned.
Example Code
- Find the position of string ab in the string abc,123,ab,c. The command example is as follows.
Returns 3.
select find_in_set('ab', 'abc,123,ab,c');
- Find the position of string hi in the string abc,123,ab,c. The command example is as follows. Returns 0.
select find_in_set('hi', 'abc,123,ab,c');
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot