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>
6.8 KiB
6.8 KiB
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.
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);
Parent topic: String Functions