PostgreSQL POSITION
From w3cyberlearnings
Contents |
Postgresql position
Locate a specific substring within a string.
Syntax position
- substring is a string to look for within a main string
- string is a main string
position(substring in string)
Example 1
test2=# SELECT position('a' in 'lost a'); position ---------- 6 (1 row) test2=# SELECT position('apple' in 'I love apple'); position ---------- 8 (1 row)
Example 2
test2=# SELECT user_firstname, test2-# position('i' in user_firstname) test2-# FROM profile; user_firstname | position ----------------+---------- Jim | 2 king | 2 Jammi | 5 Bob | 0 | (5 rows)