POSTGRESQL 中的 CHARINDEX (SQL SERVER) 是什么?

What is the CHARINDEX (SQL SERVER) equivalent in POSTGRESQL?

我正在尝试 CHARINDEX 在 Postgresql 中。但它说:

function CHARINDEX() does not exist

如果postgresql中不存在这样的内置函数,那么是否有任何函数可以替代charindex?
如果是,那么 POSTGRESQL 中的 CHARINDEX (SQL SERVER) 是什么?

postgresql 中的等效函数是:

strpos(string, substring)

或者:

position(substring in string)

它们是等价的,只是参数顺序不同。
如果你还需要参数start_location,你需要传递一个子串给strpos。

您可以在以下位置找到它们:https://www.postgresql.org/docs/current/functions-string.html