POSITION
MySQL equivalent:
Returns the position of the first occurrence of a substring in a string.
PostgreSQL 17.9
POSITION(substring IN string)- substring
- Substring to findtext
- IN string
- String to search intext
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 POSITION('om' IN 'Thomas');Case-sensitive search
PostgreSQL 17.9
SELECT POSITION('sql' IN 'PostgreSQL');Details
To search ignoring case, convert both strings to the same case: POSITION(LOWER('SQL') IN LOWER(string)). STRPOS(string, substring) does the same with the usual comma-separated arguments.