substring_index
The substring_index function is used to truncate the string str before the count-th occurrence of the separator. If count is positive, truncation starts from the left. If count is negative, truncation starts from the right.
Syntax
substring_index(string <str>, string <separator>, int <count>)
Parameters
Table 1 Parameter descriptions
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| str | Yes | STRING | The string to be truncated. |
| separator | Yes | STRING | A STRING type delimiter. |
| count | Yes | INT | Specifies the delimiter position. |
Return Values
Returns STRING type.
If any input parameter is NULL, NULL is returned.
Example Code
Returns hello.world.
SELECT substring_index('hello.world.people', '.', 2); Returns world.people.
select substring_index('hello.world.people', '.', -2); 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