array_position()
Returns the subscript of the first occurrence of the second argument in the array, or NULL if it's not present. If the third argument is given, the search begins at that subscript. The array must be one-dimensional. Comparisons are done using IS NOT DISTINCT FROM semantics, so it is possible to search for NULL.
Signature
array_position ( anycompatiblearray, anycompatible [, integer ] ) → integerExamples
SELECT array_position(ARRAY['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'], 'mon');2Run against PostgreSQL 18.6 on 2026-09-13. This is the output we got, not the documentation’s.
In other engines
| PostgreSQL | array_position |
|---|---|
| MySQL | FIND_IN_SET(needle, csv) |
| SQL Server | no direct equivalent |
| Oracle | no direct equivalent |
| SQLite | no direct equivalent |
Another consequence of PostgreSQL having arrays. FIND_IN_SET is not really the same function — it works on a comma-separated string, which is what you are forced into when the column type does not exist.
Want to run this against your own PostgreSQL server from an iPhone, iPad or Mac? These are ours — every connection goes straight from the device to your database, with no account and no server of ours in between.
Signature and description adapted from the PostgreSQL manual, used under the PostgreSQL License. PostgreSQL is a registered trademark of the PostgreSQL Community Association of Canada. This page is not affiliated with the PostgreSQL Global Development Group.