STRPOS
MySQL equivalent:
Returns the position of the first occurrence of a substring in a string.
PostgreSQL 17.9
STRPOS(string, substring)- string
- String to search intext
- substring
- Substring to findtext
Return value
An integer position starting from 1; 0 if the substring is not found; case-sensitive
Examples
Position of a substring
PostgreSQL 17.9
SELECT STRPOS('sql-academy', 'academy');Position of the space in a name
PostgreSQL 17.9
SELECT member_name,
STRPOS(member_name, ' ') AS space_position
FROM FamilyMembers;Details
STRPOS is the same as POSITION(substring IN string), but the arguments go in reverse order.