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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30778444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:59:47  来源:igfitidea点击:

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

postgresqlcharindex

提问by Manoj Soundararajan

I am trying CHARINDEXin Postgresql. But it says:

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

function CHARINDEX() does not exist

If no such inbuilt function exists in postgresql, then is there any function that serves as an alternative to charindex?
If yes, What is the CHARINDEX(SQL SERVER) equivalent in POSTGRESQL ?

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

回答by user_0

The equivalent function in postgresql is:

postgresql 中的等效函数是:

strpos(string, substring)

Or:

或者:

position(substring in string)

They are equivalent, just with different order in parameters.
If you also need parameter start_location, you will need to pass a substring to strpos.

它们是等效的,只是参数顺序不同。
如果您还需要参数 start_location,则需要将子字符串传递给 strpos。

You can find them in: https://www.postgresql.org/docs/current/functions-string.html

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