PostgreSQL starts_with() Function
The PostgreSQL starts_with()
function checks whether a string begins with a specified prefix.
starts_with()
Syntax
This is the syntax of the PostgreSQL starts_with()
function:
starts_with(string, prefix)
Parameters
string
-
Required. The string to check.
prefix
-
Required. The prefix.
Return value
The starts_with()
function returns true (t
) if the string string
starts with the specified prefix prefix
, otherwise returns false (f
).
starts_with()
Examples
This example shows how to check if a string has the specified prefix using the starts_with()
function:
SELECT starts_with('HelloWorld', 'Hello');
starts_with
-------------
t
Here, the string HelloWorld
starts with Hello
, so starts_with('HelloWorld', 'Hello')
returned t
.
SELECT starts_with('HelloWorld', 'World');
starts_with
-------------
f
Here, World
is not the prefix of the string HelloWorld
, so starts_with('HelloWorld', 'Hello')
returned f
.