Location or Position of Substring in postgresql

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 1

 

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

Location or Position of Substring 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.