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 Tutorial In this PostgreSQL tutorial youâll learn the basic data types(Boolean, char, text, time, int etc.), Querying and Filtering techniques like select, where, in, order by, etc. managing and modifying the tables in PostgreSQL. Weâll cover all the basic to advance concepts of PostgreSQL in this tutorial. 8 min read PostgreSQL DATEDIFF Function PostgreSQL doesnât have a DATEDIFF function like some other databases, but you can still calculate the difference between dates using simple subtraction. This approach allows you to find out how many days, months, or years separate two dates. In this article, we'll explore how to compute date differ 6 min read PostgreSQL - Data Types PostgreSQL is a powerful, open-source relational database management system that supports a wide variety of data types. These data types are essential for defining the nature of the data stored in a database column. which allows developers to define, store, and manipulate data in a way that aligns w 5 min read PostgreSQL - Psql commands PostgreSQL, or Postgres, is an object-relational database management system that utilizes the SQL language. PSQL is a powerful interactive terminal for working with the PostgreSQL database. It enables users to execute queries efficiently and manage databases effectively.Here, we highlight some of th 2 min read Top 50 PostgreSQL Interview Questions and Answers Are you preparing for a PostgreSQL interview? PostgreSQL is a powerful open-source relational database management system (RDBMS) that is well-known for its reliability, scalability, and rich set of features. Itâs a favorite among developers and businesses alike, making it essential to master if we w 15+ min read PostgreSQL - Create Database Creating a database in PostgreSQL is an important task for developers and database administrators to manage data effectively. PostgreSQL provides multiple ways to create a database, catering to different user preferences, whether through the command-line interface or using a graphical interface like 5 min read How to Dump and Restore PostgreSQL Database? PostgreSQL remains among the most efficient and widely applied open-source relational database management systems. It provides the superior function of saving, configuring, and extracting information most effectively. In the process of migrating data, creating backups, or transferring databases betw 6 min read PostgreSQL - SERIAL When working with PostgreSQL, we need to create tables with unique primary keys. PostgreSQL offers a powerful feature known as the SERIAL pseudo-type which simplifies generating auto-incrementing sequences for columns. In this article, weâll learn about the PostgreSQL SERIAL pseudo-type by explain h 5 min read PostgreSQL Connection String A connection string is an essential component that enables applications to communicate with databases or other data sources by providing the necessary configuration details. It consolidates critical information such as the server address, database name, user credentials, and additional parameters li 4 min read PostgreSQL - IF Statement PostgreSQL IF statement is an essential tool for implementing conditional logic within SQL queries and stored procedures. It allows developers to execute different actions based on specific conditions and enhances the flexibility of database operations. In this article, we will explore various Postg 5 min read Like