Skip to content

STRPOS

  • string: This is the source string where the search will occur. It is the text to be searched for the occurrence of the substring.
  • substring: This is the target string which will be searched in the source string. It is the text to look for within the source string.
  • returns integer: This parameter dictates that the return value of the function will be an integer. Specifically, it will return the starting position of the first occurrence of the substring within the string. If the substring is not found, the function will return 0.
SELECT STRPOS('Computer Science', 'Science') as Position;
position
----------
10
(1 row)

In this STRPOS function example, the word ‘Science’ starts at position 10 in the string ‘Computer Science’. Thus, the function returns the value 10.