MySQL Tutorial

PostgreSQL SPLIT_PART() function

SPLIT_PART() function

The PostgreSQL split_part function is used to split a given string based on a delimiter and pick out the desired field from the string, start from the left of the string.


split_part(<string>,<delimiter>, <field_number>)

PostgreSQL Version: 9.3

Pictorial Presentation of PostgreSQL SPLIT_PART() function

Pictorial presentation of postgresql split_part function

Example: PostgreSQL SPLIT_PART() function :

In the example below, the delimiter of the defined string is '-#-' and specified field number is 2. So the split_part function splits the second field from the specified string.

SELECT split_part('ordno-#-orddt-#-ordamt', '-#-', 2);

Sample Output:

(1 row)

Many of our valued users post comments along with piece of code. Disqus may, false positively, consider those piece of code as Bad or Starnge syntax and send those comments to spam automatically. Even if that happens, we will make sure those useful comments are taken out of spam and approved. It may take a couple of days for that though, but any useful comment will be brought to public view for sure. We regret if that happend to any user. You may write us directly regarding this to - w3resource[at]yahoo[dot]com.