In order to Get location or position of substring we use position () function. Position () function of column in postgresql gets the location or position. Let’s see how to
- Get location or position of substring in postgresql.
Syntax of position():
position(substring in string)
We will be using summerfruits table.
Location or position of substring in Postgresql:
To get Location or position of substring in postgresql column we use POSITION() function. With two arguments first argument is substring and second argument is string as shown below.
select *,position('e' in colour) from summerfruits
Position of substring ‘e’ is returned from Colour column. So the resultant dataframe will be