substring_index
This function is used to truncate the string before the count separator of str. If the value of count is positive, the string is truncated from the left. If the value of count is negative, the string is truncated from the right.
Syntax
substring_index(string <str>, string <separator>, int <count>)
Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
str |
Yes |
STRING |
String to be truncated |
separator |
Yes |
STRING |
Separator of the STRING type |
count |
No |
INT |
Position of the delimiter |
Return Values
The return value is of the STRING type.
If the value of any input parameter is NULL, NULL is returned.
Example Code
The value hello.world is returned.
SELECT substring_index('hello.world.people', '.', 2);
The value world.people is returned.
select substring_index('hello.world.people', '.', -2);
Feedback
Was this page helpful?
Provide feedbackThank 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