Jump to: navigation, search

PostgreSQL STRPOS

From w3cyberlearnings

Contents

Postgresql strpos

Returns the location of a substring.

Syntax strpos

strpos(string, substring)

Example 1

test2=# SELECT strpos('abc','b');
 strpos 
--------
      2
(1 row)

test2=# SELECT strpos('a powerful girl','girl');
 strpos 
--------
     12
(1 row)

Example 2

test2=# SELECT user_firstname,
test2-# strpos(user_firstname,'i')
test2-# FROM profile;
 user_firstname | strpos 
----------------+--------
 Jim            |      2
 king           |      2
 Jammi          |      5
 Bob            |      0    
(4 rows)

Related Links


Navigation
Web
SQL
MISC
References