PostgreSQL starts_with() 函数使用指南
PostgreSQL starts_with() 函数检查一个字符串是否以一个指定的前缀开头。
starts_with() 语法
这里是 PostgreSQL starts_with() 函数的语法:
starts_with(string, prefix)
参数
string- 必需的。 一个字符串。
prefix- 必需的。 一个字符串。
返回值
如果字符串 string 以指定的前缀 prefix 开头, starts_with() 函数返回 true (t),否则返回 false (f)。
starts_with() 示例
这个示例演示了如何使用 starts_with() 检查一个字符串是否拥有指定的前缀:
SELECT starts_with('HelloWorld', 'Hello');
starts_with
-------------
t这里,HelloWorld 以 Hello 开头,因此 starts_with('HelloWorld', 'Hello') 返回了 t。
SELECT starts_with('HelloWorld', 'World');
starts_with
-------------
f这里,HelloWorld 不以 World 开头,因此 starts_with('HelloWorld', 'Hello') 返回了 f。