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.
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.