Add string function split_part (#1451)
This commit is contained in:
@ -0,0 +1,42 @@
|
||||
# split_part
|
||||
|
||||
## Syntax
|
||||
|
||||
`VARCHAR split_part(VARCHAR content, VARCHAR delimiter, INT field)`
|
||||
|
||||
## Description
|
||||
|
||||
根据分割符拆分字符串, 返回指定的分割部分(从一开始计数)。
|
||||
|
||||
## Examples
|
||||
|
||||
```
|
||||
mysql> select split_part("hello word", " ", 1);
|
||||
+----------------------------------+
|
||||
| split_part('hello word', ' ', 1) |
|
||||
+----------------------------------+
|
||||
| hello |
|
||||
+----------------------------------+
|
||||
|
||||
|
||||
mysql> select split_part("hello word", " ", 2);
|
||||
+----------------------------------+
|
||||
| split_part('hello word', ' ', 2) |
|
||||
+----------------------------------+
|
||||
| word |
|
||||
+----------------------------------+
|
||||
|
||||
mysql> select split_part("2019年7月8号", "月", 1);
|
||||
+-----------------------------------------+
|
||||
| split_part('2019年7月8号', '月', 1) |
|
||||
+-----------------------------------------+
|
||||
| 2019年7 |
|
||||
+-----------------------------------------+
|
||||
|
||||
mysql> select split_part("abca", "a", 1);
|
||||
+----------------------------+
|
||||
| split_part('abca', 'a', 1) |
|
||||
+----------------------------+
|
||||
| |
|
||||
+----------------------------+
|
||||
```
|
||||
Reference in New Issue
Block a user