You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The position function in Postgres is used to find the location of the
first occurrence of a specified substring within a given string. The
result is an integer representing the character position of the
substring’s first occurrence, counting from 1. If the substring is not
found, the function returns 0.
Parameters
substring (text): The substring to search for within the given
string.
string (text): The string in which to search for the specified
substring.
Returns
The function returns an integer value representing the position of the
first occurrence of the substring within the string, or 0 if the
substring is not found.
Syntax
Description
The
position
function in Postgres is used to find the location of thefirst occurrence of a specified substring within a given string. The
result is an integer representing the character position of the
substring’s first occurrence, counting from 1. If the substring is not
found, the function returns 0.
Parameters
substring
(text): The substring to search for within the givenstring.
string
(text): The string in which to search for the specifiedsubstring.
Returns
The function returns an
integer
value representing the position of thefirst occurrence of the substring within the string, or 0 if the
substring is not found.
Examples
In these examples, the
position
function finds the location of thespecified substring within the given string.
See Also
strpos
: Finds the location of a specified substring within a givenstring.
substring
: Extracts a substring from a given string based on aspecified starting position and length.
overlay
: Replaces a portion of a string with a specifiedsubstring.
Compatibility
The
position
function is compatible with PostgreSQL and is part of theSQL standard.
The text was updated successfully, but these errors were encountered: