PostgreSQL - POSITION Function Last Updated : 18 Jul, 2024 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. Comment More infoAdvertise with us Next Article PostgreSQL - POSITION Function R RajuKumar19 Follow Improve Article Tags : PostgreSQL PostgreSQL-function PostgreSQL-String-function Similar Reads PostgreSQL MIN() Function The MIN() function in PostgreSQL is an essential aggregate function that returns the minimum value in a set of values. This function is highly useful in various data analysis and reporting tasks, allowing you to quickly identify the smallest values in your datasets. Let us better understand the MIN( 2 min read PostgreSQL - NOW() Function The NOW() function in PostgreSQL is a powerful and essential tool for retrieving the current date and time. This is particularly useful when recording actions like adding or updating records in our database. Using PostgreSQL NOW() function, we can efficiently track when events occur, making the data 4 min read PostgreSQL- LPAD Function The LPAD() function in PostgreSQL is a powerful tool for padding a string to the left, ensuring it reaches a specified length by filling it with a designated character or characters. This function can be particularly useful in data formatting and report generation.Let us better understand the LPAD F 2 min read PostgreSQL - LAG Function In PostgreSQL, the LAG() function is a powerful window function that allows you to access data from a previous row within the same result set. Itâs particularly useful for comparing values in the current row with values in the preceding row, making it ideal for analytical queries in PostgreSQL.For e 5 min read PostgreSQL - NULLIF() Function Effectively handling NULL values is important in database management, especially for ensuring data integrity and avoiding errors. PostgreSQL offers several powerful functions, such as NULLIF and COALESCE, to help manage NULL and empty values efficiently. In this article, we will guide us through the 4 min read PostgreSQL - Function Overloading In PostgreSQL, it's possible to create multiple functions with the same name, provided that each function has different arguments. This feature, known as function overloading, allows you to define functions that perform similar operations but handle different types or numbers of inputs. PostgreSQL d 3 min read PostgreSQL - LEAD Function In PostgreSQL, the LEAD() function is a powerful window function used to access a row that follows the current row at a specific physical offset. This function is generally employed to compare the value of the current row with the value of the next row following the current row.Let us better underst 3 min read PostgreSQL - Function Parameters In PostgreSQL, functions provide an efficient way to encapsulate logic, perform calculations, and handle complex tasks within a database. A thorough understanding of PostgreSQL function parameters is essential for writing flexible and optimized functions.In this article, we will analyze different ty 5 min read DATEADD() Function in PostgreSQL PostgreSQL is a powerful, open-source relational database system known for its strength and wide range of functionalities. DATEADD function in PostgreSQL adds or subtract time intervals from a given date. In this article, we will discuss basic usage, advanced interval types, and practical examples f 6 min read PostgreSQL - LAST_VALUE Function The PostgreSQL LAST_VALUE() function is a powerful window function used to retrieve the last value within a specified window frame of a query result set. It is particularly beneficial for performing advanced data analysis and retrieving the final value in ordered partitions.In this article, weâll ex 4 min read Like