VeloDB Cloud
SQL Manual
Functions
string-functions
split_part

split_part

Description

Syntax:

VARCHAR split party (VARCHAR content, VARCHAR delimiter, INT field)

This function splits the string based on the delimiter and returns the specified part of the string (counting from 1).

Example

mysql> select split_part("hello world", " ", 1);
+----------------------------------+
| split_part('hello world', ' ', 1) |
+----------------------------------+
| hello                            |
+----------------------------------+


mysql> select split_part("hello world", " ", 2);
+----------------------------------+
| split_part('hello world', ' ', 2) |
+----------------------------------+
| world                             |
+----------------------------------+

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) |
+----------------------------+
|                            |
+----------------------------+

Keywords

SPLIT_PART,SPLIT,PART