PostgreSQL - POSITION Function Last Updated : 15 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The PostgreSQL POSITION() function is used to find the location of a substring within a string. This function is particularly useful for text manipulation and searching operations within your database.Let us better understand the POSITION Function in PostgreSQL from this article.SyntaxPOSITION(substring IN string)Parameters:Let's analyze the above syntax:substring: The substring that you want to locate within the string.string: The string in which you are searching for the substring.Return Value:The POSITION() function returns the location of the searched substring in integer form that represents the location of the substring within the string. It returns zero (0) if no matching substring found.PostgreSQL POSITION Function ExamplesLet us take a look at some of the examples of POSITION Function in PostgreSQL to better understand the concept.Example 1: Finding the Position of a SubstringThe following statement returns the position of the 'Tutorial' in the string 'GeeksForGeeks Tutorial':SELECT POSITION('Tutorial' IN 'GeeksForGeeks Tutorial');Output:Explanation: This indicates that the substring 'Tutorial' starts at the 13th position of the string 'GeeksForGeeks Tutorial'.Example 2: Finding the First Instance of a SubstringThe POSITION() function returns the location of the first instance of the substring in the strings shown in the below example:SELECT POSITION('am' IN 'I am a geek');Output:Explanation: Here, the substring 'am' starts at the 3rd position of the string 'I am a geek'.Important Points About PostgreSQL POSITION FunctionThe POSITION() function is case-sensitive. If the case of the substring and the string do not match, the function will return 0.Unlike some programming languages that use zero-based indexing, PostgreSQL POSITION() returns a one-based index, meaning the first character of the string is at position 1.POSITION() only returns the position of the first occurrence of the substring.POSITION() can be effectively combined with other PostgreSQL string functions like SUBSTRING(), LENGTH(), and TRIM() for more complex string manipulations. Create Quiz Comment R rajukumar19 Follow 0 Improve R rajukumar19 Follow 0 Improve Article Tags : PostgreSQL PostgreSQL-function PostgreSQL-String-function Explore BasicsWhat is PostgreSQL - Introduction2 min readInstall PostgreSQL on Windows2 min readInstall PostgreSQL on Mac3 min readDatabase OperationsPostgreSQL - Create Database5 min readPostgreSQL - Loading a Database3 min readPostgreSQL ALTER DATABASE3 min readPostgreSQL - Rename Database4 min readPostgreSQL - Show Databases3 min readData TypesPostgreSQL - Data Types5 min readPostgreSQL - Boolean Data Type4 min readPostgreSQL - CHAR Data Type5 min readPostgreSQL - VARCHAR Data Type3 min readPostgreSQL - NUMERIC Data Type5 min readPostgreSQL - Date Data Type4 min readPostgreSQL - TIME Data Type4 min readPostgreSQL - JSON Data Type4 min readPostgreSQL - CREATE DOMAIN3 min readQuerying TablesPostgreSQL - SELECT3 min readPostgreSQL - ORDER BY clause2 min readPostgreSQL - WHERE clause6 min readPostgreSQL FETCH Clause4 min readPostgreSQL - IN operator4 min readPostgreSQL - HAVING clause4 min readPostgreSQL - GROUP BY clause4 min readPostgreSQL - LIKE operator5 min readPostgreSQL - BETWEEN Operator3 min readTable OperationsPostgreSQL - CREATE TABLE5 min readPostgreSQL - SELECT INTO4 min readPostgreSQL - CREATE SEQUENCE4 min readPostgreSQL - ALTER TABLE6 min readPostgreSQL - ADD COLUMN4 min readPostgreSQL - DROP COLUMN2 min readPostgreSQL - Rename Table2 min readPostgreSQL - DROP TABLE5 min readPostgreSQL - TRUNCATE TABLE4 min readPostgreSQL - Copy a Table3 min readPostgreSQL - Comparing Tables3 min readPostgreSQL - Show Tables4 min readModifying DataPostgreSQL - INSERT4 min readPostgreSQL - Insert Multiple Values in Various Rows3 min readPostgreSQL UPDATE Statement5 min readPostgreSQL - DELETE4 min readPostgreSQL - Upsert4 min readConditionalsPostgreSQL - CASE3 min readPostgreSQL COALESCE5 min readPostgreSQL - NULLIF() Function4 min readPostgreSQL - CAST3 min readControl FlowPostgreSQL - IF Statement5 min readPostgreSQL - CASE Statement4 min readPostgreSQL - Loop Statement3 min readPostgreSQL - While Loops4 min readPostgreSQL - Exit Statement3 min readPostgreSQL - Continue3 min readTransactions & ConstraintsPostgreSQL - Transactions4 min readPostgreSQL - COMMIT4 min readPostgreSQL - Primary Key4 min readPostgreSQL - Foreign Key5 min readPostgreSQL - CHECK Constraint2 min readPostgreSQL - UNIQUE Constraint3 min readPostgreSQL - NOT NULL Constraint3 min readJOINS & SchemasPostgreSQL - Joins5 min readPostgreSQL - LEFT JOIN5 min readPostgreSQL - INNER JOIN2 min readPostgreSQL - FULL OUTER JOIN4 min readPostgreSQL - SELF JOIN4 min readPostgreSQL - Schema5 min readPostgreSQL - CREATE SCHEMA5 min readPostgreSQL - DROP SCHEMA4 min readPostgreSQL - ALTER SCHEMA3 min read Like