Extract the substring of the column in Postgresql

In order to extract the substring of the column in postgresql we use SUBSTRING() function. SUBSTRING() Function in postgresql gets the substring of given string. Let’s see how to

  • Get substring from string in postgresql using SUBSTRING() function.

Syntax:

SUBSTRING (string ,start_position , length )

We will be using states table.

Extract substring of column in postgresql 1

 

Get substring of the column in Postgresql

Substring of the column in postgresl is extracted using SUBSTRING() function

select *, substring(state_name,1,7) as State_name_new from states

So the resultant dataframe will be.

Extract substring of column in postgresql 2

 

                                                                                                   

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.

    https://www.linkedin.com/in/sridhar-venkatachalam-74414252/ karaimadai@sg2plcpnl0204.prod.sin2.secureserver.net Venkatachalam Sridhar